L
Lloyd Dupont
In my application I download a file in the background.
With code like below:
====
Stream input;
new Thread(delegate(){
int nRead, total = 0;
byte[] buf = new byte[4096];
using(FileStream output = new FileStream("output", FileMode.Create,
FileAccess.Write))
while((nRead = input.Read(buf, 0, buf.Length) > 0)
output.Write(buf, 0, nRead);
}).Start();
====
Where input is a network stream (http://something), comes from a
WebRequest.GetResponse().GetResponseStream().
Now some customer experience repeatedly problem wit that. But as I
experience none it's hard to debug.
One customer reported the following exception:
====
Exception : System.IO.IOException
Message?? : The process cannot access the file 'C:\Documents and
Settings\gavin\Local Settings\Application Data\NovaMind
Software\NovaMindEditor\3.0.7.0\NovaMindEditor-3_0_8-Setup.exe' because it
is being used by another process.
Source??? : mscorlib
Help ?????:
Stack??? :
?? at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
?? at System.IO.FileStream.Init(String path, FileMode mode, FileAccess
access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize,
FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean
bFromProxy)
?? at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access)
====
But this is the only place in the program, called only once, so why could
that be?
With code like below:
====
Stream input;
new Thread(delegate(){
int nRead, total = 0;
byte[] buf = new byte[4096];
using(FileStream output = new FileStream("output", FileMode.Create,
FileAccess.Write))
while((nRead = input.Read(buf, 0, buf.Length) > 0)
output.Write(buf, 0, nRead);
}).Start();
====
Where input is a network stream (http://something), comes from a
WebRequest.GetResponse().GetResponseStream().
Now some customer experience repeatedly problem wit that. But as I
experience none it's hard to debug.
One customer reported the following exception:
====
Exception : System.IO.IOException
Message?? : The process cannot access the file 'C:\Documents and
Settings\gavin\Local Settings\Application Data\NovaMind
Software\NovaMindEditor\3.0.7.0\NovaMindEditor-3_0_8-Setup.exe' because it
is being used by another process.
Source??? : mscorlib
Help ?????:
Stack??? :
?? at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
?? at System.IO.FileStream.Init(String path, FileMode mode, FileAccess
access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize,
FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean
bFromProxy)
?? at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access)
====
But this is the only place in the program, called only once, so why could
that be?