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
Vadym Stetsiak - 11 Sep 2007 15:47 GMT
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 - 11 Sep 2007 17:46 GMT
FileStream fsDoc = new FileStream(_filename, FileMode.Create);
byte[] blob = (byte[])_myDS.myDataTable[0].myDoc;
fsDoc.Write(blob, 0, blob.Length);
fsDoc.Close();
fsDoc = null;
> Hello, randy1200!
>
[quoted text clipped - 14 lines]
> r> Thanks,
> r> Randy
Hilton - 12 Sep 2007 00:51 GMT
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
> FileStream fsDoc = new FileStream(_filename, FileMode.Create);
> byte[] blob = (byte[])_myDS.myDataTable[0].myDoc;
[quoted text clipped - 20 lines]
>> r> Thanks,
>> r> Randy
Tim Sprout - 11 Sep 2007 17:24 GMT
> I'm working on an application that opens, edits, and closes Microsoft Word
> 2002 documents. During the debugging process, there are many instances were
[quoted text clipped - 4 lines]
> Thanks,
> Randy
Try Unlocker:
ccollomb.free.fr/unlocker
--Tim Sprout
Ben Voigt [C++ MVP] - 12 Sep 2007 16:49 GMT
> I'm working on an application that opens, edits, and closes Microsoft Word
> 2002 documents. During the debugging process, there are many instances
[quoted text clipped - 4 lines]
> 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.
> Thanks,
> Randy