Results 1 to 2 of 2

Thread: How to check if a file is being used by another process.

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    734

    Question 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.
    If your problem has been solved then please mark the thread [RESOLVED].
    If i have helped then please Rate my post

  2. #2
    Frenzied Member stimbo's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    1,739

    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.
    Last edited by stimbo; Jan 22nd, 2007 at 06:20 AM.
    Stim

    Free VB.NET Book Chapter
    Visual Basic 2005 Cookbook Sample Chapter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width