Deleting Locked Files

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm working on an application that opens, edits, and closes Microsoft Word
2002 documents. During the debugging process, there are many instances were
the application does not terminate property and close the word file. Is there
any way to delete these word files without having to reboot the PC to release
the lock?

Thanks,
Randy
 
Hello, randy1200!

How do you open these Word files?

--
With best regards, Vadym Stetsiak.
Blog: http://vadmyst.blogspot.com

You wrote on Tue, 11 Sep 2007 06:56:03 -0700:

r> I'm working on an application that opens, edits, and closes Microsoft
r> Word 2002 documents. During the debugging process, there are many
r> instances were the application does not terminate property and close
r> the word file. Is there any way to delete these word files without
r> having to reboot the PC to release the lock?

r> Thanks,
r> Randy
 
randy1200 said:
I'm working on an application that opens, edits, and closes Microsoft Word
2002 documents. During the debugging process, there are many instances were
the application does not terminate property and close the word file. Is there
any way to delete these word files without having to reboot the PC to release
the lock?

Thanks,
Randy

Try Unlocker:

ccollomb.free.fr/unlocker

--Tim Sprout
 
FileStream fsDoc = new FileStream(_filename, FileMode.Create);
byte[] blob = (byte[])_myDS.myDataTable[0].myDoc;
fsDoc.Write(blob, 0, blob.Length);
fsDoc.Close();
fsDoc = null;
 
Randy,

Use "using (FileStream fsDoc = new FileStream (this.filename,
FileMode.Create)" instead.

To 'unlock' the file, just rename it to something else - kinda wierd you can
do this to a locked file, but for testing purposes this allows to to run
through numerous debug sessions, then at the end just reboot and delete all
the renamed files.

Hilton


randy1200 said:
FileStream fsDoc = new FileStream(_filename, FileMode.Create);
byte[] blob = (byte[])_myDS.myDataTable[0].myDoc;
fsDoc.Write(blob, 0, blob.Length);
fsDoc.Close();
fsDoc = null;

Vadym Stetsiak said:
Hello, randy1200!

How do you open these Word files?

--
With best regards, Vadym Stetsiak.
Blog: http://vadmyst.blogspot.com

You wrote on Tue, 11 Sep 2007 06:56:03 -0700:

r> I'm working on an application that opens, edits, and closes Microsoft
r> Word 2002 documents. During the debugging process, there are many
r> instances were the application does not terminate property and close
r> the word file. Is there any way to delete these word files without
r> having to reboot the PC to release the lock?

r> Thanks,
r> Randy
 
randy1200 said:
I'm working on an application that opens, edits, and closes Microsoft Word
2002 documents. During the debugging process, there are many instances
were
the application does not terminate property and close the word file. Is
there
any way to delete these word files without having to reboot the PC to
release
the lock?

Windows will not allow an application to keep a file locked after the
process exits. So make sure that the process is exited. While debugging,
this might mean restarting Visual Studio, but you should not need a reboot.
 
Back
Top