Home All Groups Group Topic Archive Search About
Author
25 Mar 2005 9:54 PM
Nikolay Petrov
How to check if the file, that i need to write to is locked, and if so
wait some time then try again?

Author
26 Mar 2005 8:49 AM
Crouchie1998
Try to open it in a try-catch-end try block & if you get a FileIOException
then its already open
Author
26 Mar 2005 12:23 PM
Herfried K. Wagner [MVP]
"Nikolay Petrov" <johnt***@mail.bg> schrieb:
> How to check if the file, that i need to write to is locked, and if so
> wait some time then try again?

Try to open the file with 'FileShare.None' and catch the exception which is
thrown when the file is already in use.  You can use a timer control to
periodically check the file until it can be opened.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
26 Mar 2005 8:53 PM
Nikolay Petrov
Thanks Crouchies, thanks Herfried