Results 1 to 3 of 3

Thread: Check if file is locked?

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2004
    Location
    LA
    Posts
    57

    Question Check if file is locked?

    Hello guys,

    I’m writing a program that need’s to delete a Folder with the bunch of files witch is not a problem. The problem is how I can check if the file inside the folder is in use or open by another program.

    Thank you.

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    VB Code:
    1. Try
    2.          openFile = System.IO.File.Open(fileName, FileMode.Open, FileAccess.ReadWrite, FileShare.None)
    3.    Catch fileinuse As System.IO.IOException
    4.          ' file is in use
    5.    End Try
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3
    Hyperactive Member
    Join Date
    Apr 2010
    Posts
    420

    Re: Check if file is locked?

    Once the above test has been carried out, if the file is not locked, will it then be open by this programme. As such if you want to delete it, you will have to close it first ?

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