CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Open File Check

  1. #1
    Join Date
    Aug 2001
    Location
    PA
    Posts
    150

    Open File Check

    Is there a way or function that indicate if a file is open.

    Thanks

    Thanks
    Hisham
    Thank You, Hisham

  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Open File Check

    dim intFreeFile as Integer
    intFreeFile = FreeFile
    On Error Resume Next

    Open "c:\MyPath\Myfile" For Binary Access Read Write Lock Read Write As intFreeFile

    If Err.Number <> 0 Then
    MsgBox "File Is Busy"
    End If

    Close (intFreeFile)

    On Error GoTo 0


    '=====another example=========
    Public Declare Function GetFileAttributes Lib "kernel32" Alias "GetFileAttributesA" (ByVal lpFileName As String) As Long

    dim testfile as string

    testfile = "\\server1\c\myapp\reading.flg"

    If (GetFileAttributes(testfile) = &HFFFFFFFF) Then
    Open fname$ For Output As #1
    Print #1,"R"
    Close #1

    <<code here to open the file>>

    Else
    MsgBox "Someone is reading the file"
    End If

    -- end code --



    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

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

Featured