Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / September 2007

Tip: Looking for answers? Try searching our database.

Deleting Locked Files

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
randy1200 - 11 Sep 2007 14:56 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
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.