Checking if file is open on network

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sdf.ska@gmail.com

    #1

    Checking if file is open on network

    I have a simple function that returns a boolean depending on if a file
    is in use on a local drive. (looking to see if a file is finished
    being written to by another app) Works great from a local drive but
    when I send it a unc path to the same folder, it does not work. my
    question is Why? and or if anyone has a better solution to see if a
    file is being used exclusively on a network share, i would be
    interested to know.
    Thanks
    here is the function:
    '-----
    Private Function GetExclusiveAcc ess( _
    ByVal theFilePath As String) As Boolean
    Try
    Dim strm As Stream = IO.File.Open(th eFilePath, _
    IO.FileMode.App end, _
    IO.FileAccess.W rite, _
    IO.FileShare.No ne)
    'if we succeed, we can let it go
    strm.Close()
    GetExclusiveAcc ess = True
    Catch e As Exception
    'Console.WriteL ine("Error opening input file " & _
    'theFilePath & " exception info: " & e.Message)
    GetExclusiveAcc ess = False
    End Try
    End Function

Working...