Is file locked?

evanheld

Member
Joined
Nov 20, 2003
Messages
13
Location
Sarasota, FL
What is the .NET way to determine if a file is locked? I am getting a file from an FTP directory, and sometimes the file is not finished being copied when my .NET service picks it up.

How can I tell if a file is locked?

Thanks!
 
Found the best way

I was checking the file size and sleeping 5 seconds, but it gave me unreliable results.

The best way is to put a try/catch block aroud the open and if an IOException is thrown have the thread sleep for a while (a couple seconds, say) and try again.

(Thank you DarrellNorton, dotnetjunkies.com answered on WWW.ASP.NET forums.)
 
Back
Top