open file??

wsyeager

Well-known member
Joined
Apr 10, 2003
Messages
140
Location
Weston, FL
Is there any way to tell if a file is "Open"? I tried looking into some properties on the system.io class, but couldnt seem to find anything about that.......
 
:)

Try using the Try Catch statement when opening the file, so like this:

[VB] Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

//The string that holds the path of the file
Dim strPath As String
strPath = "C:\Text.txt"

//This will see if the file is actually there
Dim Exist As Boolean
Exist = System.IO.File.Exists(strPath)

//If the file is not there then exit sub
If Exist = False Then Exit Sub

Try
Dim writer As New IO.StreamWriter("C:\Text.txt")
Catch
MessageBox.Show("The file is busy; the file is already opened and cannot be opened right now")
End Try

End Sub
[/VB]
 
Back
Top