Grimtaz

Grimtaz

  • NA
  • 3
  • 0

Having real problems with BinaryWriter file access

Feb 27 2006 3:10 PM

Ok so I'm tearing my hair out.  I've been trying for the last 2hrs to get this thing to work like it's supposed to. I have a binary file which I need to create or overwrite multiple times because the data is changing frequently.

Here is the code I'm using:

BinaryWriter dataOut = new BinaryWriter(new FileStream(datfilename, FileMode.Create, FileAccess.Write));

dataOut.Write(data);
....
....
dataOut.Close();

It works first time. But when called a second time it gives the error "The process cannot access the file .... because it is being used by another process."

Thats rubbish! It's been closed!!

Can somone please help me out??


Answers (1)