cannot access the file ...

  • Thread starter Thread starter Iain
  • Start date Start date
I

Iain

I've a winforms app which writes files to another machine (through a UNC
path). The other machine does something clever with it and then writes a
result file to let me know that it has done.

I start by creating a folder then write my files in it and when I see the
'done' file I delete the folder.

I get an error on the delete claiming that another process has the file
(directory) open.

All the files IN the directory get deleted.

If I create several such directories on the trot it seems only the last one
that refuses to be deleted.

Once I shut my program down (and close VS2003) I still cannot delete it.

I cannot delete it from my local machine (same error), but if I go to the
remote machine I can delete it there.

Process Explorer from sysinternals cannot find anything locking it on either
machine.

I suspect this is a Windows issue not winforms per se except I have written
near as damnit the same program in VB and it does not do this.

Can anyone suggest how I can diagnose this?

Iain

Oh - I run GC.Collect after writing my files - this uses a com object and
I've had issues with these holding onto resources if they are not explicitly
cleaned up.
 
Thanks, I'll try that.

Oddly this problem simply does not happen on another machine I tried it on
(same OS, same patches ...)

Iain
Saurabh Nandu said:
hi,

The last note you wrote seems to point to the suspicious part of your problem.

Make sure you call
System.Runtime.InteropServices.Marshall.ReleaseComObject if you are using a
COM Object to explicitly decriment the reference count of the COM object so
that it releases the handel to the file.
Also make sure that all the File Handles are explicitly Disposed/Closed


--
Regards,
Saurabh Nandu
AksTech Solutions, reflecting your needs...
[ www.AksTech.com ]
[ www.MasterCSharp.com ]



Iain said:
I've a winforms app which writes files to another machine (through a UNC
path). The other machine does something clever with it and then writes a
result file to let me know that it has done.

I start by creating a folder then write my files in it and when I see the
'done' file I delete the folder.

I get an error on the delete claiming that another process has the file
(directory) open.

All the files IN the directory get deleted.

If I create several such directories on the trot it seems only the last one
that refuses to be deleted.

Once I shut my program down (and close VS2003) I still cannot delete it.

I cannot delete it from my local machine (same error), but if I go to the
remote machine I can delete it there.

Process Explorer from sysinternals cannot find anything locking it on either
machine.

I suspect this is a Windows issue not winforms per se except I have written
near as damnit the same program in VB and it does not do this.

Can anyone suggest how I can diagnose this?

Iain

Oh - I run GC.Collect after writing my files - this uses a com object and
I've had issues with these holding onto resources if they are not explicitly
cleaned up.
 
Back
Top