Thanks Mr. Daniel.
I have added some more code to my application.
The following is the new code:
if (byteCount == 0)
{
stream.Close();
return;
}
byte[] bytes = new byte[byteCount];
stream.Lock(0, byteCount);
stream.Read(bytes, 0, byteCount);
stream.SetLength(0);
stream.Unlock(0, byteCount);
stream.Close();
Eventhough Iam getting the same exception. Can you please explain me
what is the cause?
Thanks,
GVN.
What happens is byteCount is not 0? You still have the file open, unless
there's code that you didn't show that closes it.
That error indicates that you haven't closed the file after opening it the
first time. Make sure that you call FileStream.Close (or Dispose) when
you're done with the file. FileShare.None means that you can't even share
access to the file with yourself, so you can have only one open handle to
the file at a time.
-cd