In message <11************ **********@z14g 2000cwz.googleg roups.com>,
"Alexandre (www.pointnetso lutions.com)" <al************ *****@gmail.com >
writes
this only occurs when i write a new file and then try to over write it.
if the thread finishes and starts overagain i am able to overwrite a
file that already exists as often as i want..
Are you using a filestream to write to disk? Is it in a using block /
being cleaned up manually? The example below does not error. Remove the
'using' block, and you get a file locked exception:
"An unhandled exception of type 'System.IO.IOEx ception' occurred in
mscorlib.dll
Additional information: The process cannot access the file "I:\x.dat"
because it is being used by another process."
static void Main(string[] args)
{
WriteFile();
WriteFile();
Console.Read();
}
static void WriteFile()
{
Foo foo = new Foo();
BinaryFormatter bf = new BinaryFormatter ();
using(FileStrea m fs = new FileStream(@"I: \x.dat",FileMod e.Create))
{
bf.Serialize(fs ,foo);
}
}
--
Steve Walker