Click to See Complete Forum and Search --> : Open File Check


hoa01206
September 20th, 2001, 10:42 AM
Is there a way or function that indicate if a file is open.

Thanks

Thanks
Hisham

Iouri
September 20th, 2001, 10:47 AM
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
iouri@hotsheet.com