|
Thanks for your replay.
can you explain your answer for better understanding?
Thanks in advance.
|
|
|
|
|
You can try something like this. I have modified your code slightly to place reading and writing inside the main loop. Also, I recommend having your streams inside a using block, it is simpler to write and safer if any exception is thrown.
Note: This code is untested!!
public static void Download(String strURLFileandPath, String strFileSaveFileandPath)
{
HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(strURLFileandPath);
HttpWebResponse ws = (HttpWebResponse)wr.GetResponse();
byte[] inBuf = new byte[100000];
int bytesToRead = (int)inBuf.Length;
int bytesRead;
using (Stream str = ws.GetResponseStream())
{
using (FileStream fstr = new FileStream(strFileSaveFileandPath, FileMode.OpenOrCreate, FileAccess.Write))
{
try
{
while ((bytesRead = str.Read(inBuf, 0, bytesToRead)) > 0)
{
fstr.Write(inBuf, 0, bytesRead);
}
}
catch (Exception e) {
MessageBox.Show(e.Message);
}
}
}
}
|
|
|
|
|
Hi All,
I have come across a problem if I run an Executable built in VS 2008 to check the validity of some drivers for a purpose the first version I wrote errors after it has run and is about to exit, a second version the quicker version, wont run at all!
FileVersionInfo fsi = FileVersionInfo.GetVersionInfo(@"C:\Windows\system32\drivers\ftdibus.sys");
String AppPath = Directory.GetCurrentDirectory();
is the code encounter when it loads the form, Could this blow it out of the water as the try...catch I added is not operating at all, also the previous version ueses
ServiceController[] scDevices = ServiceController.GetDevices(); and then loads a list with the driver details and crashes after. As these programs both work on my dev PC, at least two other (XP & 7) but wont work on the older machines (2) (both XP) I'm starting to worry about Works on my PC syndrome! (could it be an issue with Service packs?)
Glenn
|
|
|
|
|
glennPattonWork wrote: Could this blow it out of the water as the try...catch I added is not operating at all,
In that case, the EventLog would be the first place to look for clues.
glennPattonWork wrote: and then loads a list with the driver details and crashes after.
Under what user are you executing the app? Is UAC enabled?
You can put the SharpDevelop-IDE on a USB-stick, and use that to debug the app on the machines where Visual Studio isn't installed. If the exception-handler is bypassed, you could try simple logging to get an indication where the application exits.
Not much help I'm afraid, but at least a starting-point.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
The EventLog mmm, give that a go.
As for users I assume admin rights but I just go check.
Hey-Ho I'm Back it appears to .NET2.0RunTime throwing an error 5000 on both machines which according to MSDN "This problem occurs because the default policy for unhandled exceptions has changed in the .NET Framework 2.0. By default, the policy for unhandled exceptions is to end the process." Prior to .Net2.0 it ignores." which is helpful
There does seem to be a bit on the .Net2.0 frame work not being installed properly, seems like a good time to do an update on both PC's one takes about 25 mins to boot and the other is a test laptop that dies if look at it wrong!
Glenn
modified 26-Jul-12 10:49am.
|
|
|
|
|
glennPattonWork wrote: Hey-Ho I'm Back it appears to .NET2.0RunTime throwing an error 5000 on both machines which according to MSDN "This problem occurs because the default policy for unhandled exceptions has changed in the .NET Framework 2.0. By default, the policy for unhandled exceptions is to end the process." Prior to .Net2.0 it ignores." which is helpful
Means that since .NET 2.0 the application dies if you have an unhandled exception.
glennPattonWork wrote: There does seem to be a bit on the .Net2.0 frame work not being installed properly, seems like a good time to do an update on both PC's one takes about 25 mins to boot and the other is a test laptop that dies if look at it wrong!
Did the repair help?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Oh boy I can see a day if Try Catch hell in front of me, the first attempt at re-installing all the available frame works didn't work, trying again after a night rest.
Well I have the laptop on my desk from the lab, it now looks as if the issue is caused by machines that don't have a component installed as I tried it another Windows 7 laptop and it died.
Glenn
-=-=-=-=-=-=-=-=-=-=-=-=-=-
EDIT
=-=-=-=-=-=-=-=-=-=-=-=-=-=
FileVersionInfo fsi = FileVersionInfo.GetVersionInfo(@"C:\Windows\system32\drivers\ftdibus.sys");
This was the line that was causing the program to crash! moved it to inside a button click all is well (now just to find a good try catch!)
Glenn
modified 27-Jul-12 7:52am.
|
|
|
|
|
Iam trying to cancel the RowValidating event in a dataGridview but but after cancelling the event, am not returned to the grid so i can edit the row that was being validated.
In my Grid, if the isCreditSale column value is True and CustomerID column value is Empty, i want to cancel the event, tell the user what the error is, and return the user to the grid so they can edit the row cell values.
Unfortunately, when the messagebox pops up, it never goes away even if you click ok 100 times not until you just terminate the process.
This is the sample code,
private void dataGridView1_RowValidating(object sender, DataGridViewCellCancelEventArgs e)
{
if (dataGridView1.Rows[e.RowIndex].IsNewRow)
{
return;
}
string customer = dataGridView1.Rows[e.RowIndex].Cells["customerID"].FormattedValue.ToString();
decimal paid;
decimal.TryParse(dataGridView1.Rows[e.RowIndex].Cells["amountPaid"].FormattedValue.ToString(), out paid);
bool isCredit;
bool.TryParse(dataGridView1.Rows[e.RowIndex].Cells["isCreditSale"].FormattedValue.ToString(), out isCredit);
if (isCredit == true && string.IsNullOrEmpty(customer))
{
MessageBox.Show("Please enter a customer name for this credit sale", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
e.Cancel = true;
}
}
|
|
|
|
|
Hello Martin
at the msdn RowValidating page there is a line which recommends you to:"If the row does not pass validation, set the CancelEventArgs.Cancel property to true."
this should prevent the event from occuring more times.
Here the LINK
i hope this helps you at least a bit.
|
|
|
|
|
There's both a RowValidating and a <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.cellv">CellValidating</a>[<a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.cellv" target="_blank" title="New Window">^</a>] event. The MSDN-page has an example on validating a cell.
If you show a MessageBox, the editing of the cell must have finished (since the cursor and focus exit and go to the messagebox) - hence, the value in the cell must be already corrected, or reset.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Sir: I want to write freehand text in per-define size picture box using USB Pen in pen mode (not in mouse mode) for than I want to use Microsoft.Ink & Strokes, I am using Pegasus SDK in that I get Pen_MoveDown, Pen_Move, Pen_Up events : In this I getting X,Y values of Pen Tip. But how to write/Use this X,Y values (Strokes) in free hand text writing
Please Help me.
Yogi Patil
|
|
|
|
|
It's just a matter of capturing the co-ordinates each time the pen moves and drawing a line between each, and saving them in an array of some type to recreate later. However without some more specific details about what part you are having trouble with, it is difficult to offer a complete answer. There is a C++ sample application called Scribble, which may give some useful information: take a look at these links[^].
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I have digital pen connect throug USB device, that device i attach with paper, through pen i write on paper, that must be display on my app. picture box what i write, but my problem is that while writing on paper i get x & y coordinates in bigger value like x=-1122 & y=3458 : on pen_move I try to write/draw that value in picture box but it not display because of bigger value of xy coordination: So I want to convert that getting xy coordination to normal form of picture box : but to it covert in vc++ some one try this like :
return CPoint( ::MulDiv( Event.XPos + 10500 / 2, m_rtPage.Width(), 10500 ) + m_rtPage.left,
::MulDiv(Event.YPos, m_rtPage.Height(), 12200 ) + m_rtPage.top );
how to convert this in C# from vc++ code
plz help me
|
|
|
|
|
It may be a better idea to read the documentation for the pen device to discover what these co-ordinate values represent. For reference you can also check the C++ MulDiv() function[^].
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Hi everybody
I'm trying to send udp packets using C# Socket class. Each packet has 1024 bytes and I send packets each 5 miliseconds. It cause my system cpu usage to go more than 50% which I beleive is not natural. does anyone have any idea about my problem?
|
|
|
|
|
asghari_mohsen wrote: does anyone have any idea about my problem?
It sounds as though you wrote incredibly inefficient code. Without seeing it, it's pretty much impossible to tell you what's going on. You might want to update your question to include the code where you are sending packets and/or assembling the data to send.
|
|
|
|
|
Thank you so much Dave.
I got my answer somehow, as soon as I post this thread.
I was thinking maybe the number of packets are too much. But as you said, It was a problem in my code.
Thank you again.
|
|
|
|
|
Hi world !
How to compare the files byte-by-byte via C# to get diffrence between them.
( cause i have read document that says if you compare the files byte-by-byte it will get every diff such as modify,size,...)
thanks in advanced!
|
|
|
|
|
ReadAllBytes from both files and loop through them. What's the problem?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Oh come on!
You have been here for over two years, and have posted over 200 messages.
You know what to do: start with google.
A very quick search "How to compare the files byte-by-byte via C#"[^] gave over 3 million hits, with Microsoft in third place...
How to create a File-Compare function in Visual C#[^]
In future, please try to do at least basic research yourself, and not waste your time or ours.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
I'm trying to mash the "5" button about 2 millions times, but, sadly, it'll only let me do it once...
|
|
|
|
|
+5
He might be a very slow learner
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Either that or a Real Programmer - see your sig...
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
|
thanks everyone!
I got the solution .
|
|
|
|