How to check if a file is being used by another process.
Hi guys,
I have been getting this same error over and over again and i was just wondering if there was anyway to get around it by performing a check. I am currently downloading an xml file with image locations in and storing them in a local folder. I am then going through the images and displaying them on my screen (all the images are stored in an array and then i go through the array and display the images.) Now i keep getting an error which says:
The process cannot access the file 'filename' because it is being used by another process.
And i was just wondering whether there was any way i could do a test on this before i display the image so it will avoid displaying this error.
Thanks in advance for any help.
:afrog:
Re: How to check if a file is being used by another process.
I don't know if this is available in the compact framework but there's a
DownloadDataCompletedEventArgs
class. Check to see if it exists under the Imports: System.Net
Think this example may help
MSDN
I think the webclient also has some features that may help like: IsBusy etc...
Alternatively, if none of that is helpful then you could as a rough work-around put it in a Try block and if an exception happens start a timer (without a message if you wish) to try again in a certain amount of time.