By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,556 Members | 1,448 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,556 IT Pros & Developers. It's quick & easy.

Locked files

P: n/a
How to check if the file, that i need to write to is locked, and if so
wait some time then try again?

Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Try to open it in a try-catch-end try block & if you get a FileIOException
then its already open
Nov 21 '05 #2

P: n/a
"Nikolay Petrov" <jo******@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/>

Nov 21 '05 #3

P: n/a
Thanks Crouchies, thanks Herfried

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.