D
Daniel
I have an winform application that uses System.IO.StreamReader and
Serializer.Deserialize to load some data from a file, if any error is
detected in the file a new file should be written to the same
directory, I use a StreamWriter and Serializer.Serialize to do this.
The problem is that when the streamreader has opened the file it does
not release it until the application is closed.
When I try to use the StreamWriter to write the new file I thus get
"System.IO.IOException: The process cannot .... because it is being
used by another process".
I have tried with closing the streamreader (obviously) and setting all
possible objects to nothing as well as call the gc explicitly. Using
Process explorer from sysinternals I can close the handle to the file
if I use the IDE and take it step by step and then it works.
Any and all ideas welcome
/Daniel
Serializer.Deserialize to load some data from a file, if any error is
detected in the file a new file should be written to the same
directory, I use a StreamWriter and Serializer.Serialize to do this.
The problem is that when the streamreader has opened the file it does
not release it until the application is closed.
When I try to use the StreamWriter to write the new file I thus get
"System.IO.IOException: The process cannot .... because it is being
used by another process".
I have tried with closing the streamreader (obviously) and setting all
possible objects to nothing as well as call the gc explicitly. Using
Process explorer from sysinternals I can close the handle to the file
if I use the IDE and take it step by step and then it works.
Any and all ideas welcome
/Daniel