using serialization to serialize my objects to hard drive

  • Thread starter Thread starter Alexandre (www.pointnetsolutions.com)
  • Start date Start date
A

Alexandre (www.pointnetsolutions.com)

Hey im using serialization to serialize my objects to hard drive,
reading them is no problem but overwriting them causes me problems,i
have un authorized access to the files but i gave the folder all the
permissions.

source:
http://www.vkarlsen.no/pastebin/default.asp?id=5545

can someone tell me what im not doing right
 
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..
 
"Alexandre (www.pointnetsolutions.com)" <[email protected]>
wrote in message
Hey im using serialization to serialize my objects to hard drive,
reading them is no problem but overwriting them causes me problems,i
have un authorized access to the files but i gave the folder all the
permissions.

source:
http://www.vkarlsen.no/pastebin/default.asp?id=5545

can someone tell me what im not doing right

Please post the exact exception message.
You should also post the complete code that illustrates the problem you
have, not a few methods like you did now.

Willy.
 
In message <[email protected]>,
Alexandre (www.pointnetsolutions.com) said:
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.IOException' 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(FileStream fs = new FileStream(@"I:\x.dat",FileMode.Create))
{
bf.Serialize(fs,foo);
}
}
 
Additional information: The process cannot access the file "I:\x.dat"
because it is being used by another process."

is the exact error im getting this is all on a webservice, and i am
using the user statment "block" and i still get this error when i
create a new fresh file where i overwrite the file im alright.

it seems that when i create a new filei have to wait for the gc to
dispose of the application thread to release everything before i can
overwrite....

i find this quite strange because the code is clean and should work i
juste cannot find anything wrong with it.

if any one can give me some light on this i would be greatful...

Alexandre
 
In message <[email protected]>,
Alexandre (www.pointnetsolutions.com) said:
Additional information: The process cannot access the file "I:\x.dat"
because it is being used by another process."

is the exact error im getting this is all on a webservice, and i am
using the user statment "block" and i still get this error when i
create a new fresh file where i overwrite the file im alright.

it seems that when i create a new filei have to wait for the gc to
dispose of the application thread to release everything before i can
overwrite....

I think you need to post the code.
 
i am using this code in a web service, therefore i truely have no idea
why it causes this problem like you have experienced this code works
great locally
 
If you are trying to write to a file from a webservice you may have threading
issues as multiple requests would be trying to write to the same file.
 
Back
Top