P
Parrot
I am creating a file in my WIndows based C# program with the following command:
FileStream fs1 = new FileStream(filename, FileMode.Create,
FileAccess.ReadWrite, FileShare.ReadWrite);
StreamWriter sr = new StreamWriter(fs1);
I then write records to the file and then close both the FileStream and the
Streamwriter with the following commands:
sr.Close();
sr.Dispose();
fs1.Close();
fs1.Dispose();
Later in the program I try to create the file again. 50% of the time I get
an error message saying the the file is currently being used by another
process. Can anyone tell me why I get this error and how I can get around
this error?
Dave
FileStream fs1 = new FileStream(filename, FileMode.Create,
FileAccess.ReadWrite, FileShare.ReadWrite);
StreamWriter sr = new StreamWriter(fs1);
I then write records to the file and then close both the FileStream and the
Streamwriter with the following commands:
sr.Close();
sr.Dispose();
fs1.Close();
fs1.Dispose();
Later in the program I try to create the file again. 50% of the time I get
an error message saying the the file is currently being used by another
process. Can anyone tell me why I get this error and how I can get around
this error?
Dave