Is there a way or function that indicate if a file is open.
Thanks
Thanks
Hisham
Printable View
Is there a way or function that indicate if a file is open.
Thanks
Thanks
Hisham
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]