When try to open a file in Vb 6.0, I am getting error 'file already open'. Is there any way to check, if the file is open or not, so that I need to open the file again. The file is stored on a network so I do'nt have too much control over the file.
VB returns error 55 if the file is open. Check for the error number. CLose the file if you encounter the error and then re-open it..
Sample:
Private Sub Command1_Click()
On Error GoTo Errh
Open "C:\Temp.txt" For Input As #2
MsgBox "File opened sucessfully"
Errh:
If Err.Number <> 0 Then
If Err.Number = 55 Then
MsgBox "File is open lets close it."
Close #2
Else
MsgBox Err.Number & " " & Err.Description
End If
End If
End Sub
That helps in general, but in my case I did not open the file and have to get access. Is there any way to find out which application has grabbed access / opened the file? Or is there any possibility to force close - so that I may get access?
-- same questions to permission denied - error 70
Thanks
You can get many programs from this site. One is FileMon which will let you know what process has a file open. They also have PSKILL which will let you kill the process that you choose.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.