Read error (stream)

  • Thread starter Thread starter csharpula csharp
  • Start date Start date
C

csharpula csharp

Hello,I am trying to read from a zip stream and one of the files is of a
0 size (0 bytes)- Exception is thrown as a result but there are some
other files after it in a stream which I want to keep reading and
writing to temp dir. How can I deal such exception.

I get error when in the end I want to erase the temp dir and it won't
let me because the 0 bytes file is being used by other process.
How to solve it?
Thank you!
 
Hi
I think you missed to close the stream object if exception occurs.

Regards
Rahul.
 
In the catch part I did :

streamWriter.Close();
zipInputStream.CloseEntry()

but it's not helping and when I am trying to erase the temp dir,the 0
bytes file is been holden by some other proces.
How could it be?
Thanks!
 
Why is there an exception just because the file size is zero? What
object is throwing the exception?

If possible, try to handle the zero size files without using exceptions.
 
Not sure if you want it in catch maybe in a finally.

But try to find the filesize before committing it to a stream is probably
the best option.
 
Back
Top