File Mode Question

lpaul

Active member
Joined
Dec 7, 2005
Messages
27
Programming Experience
Beginner
I am trying to see if a file is open and being used (written to) by another program before I try to read the file. And if it is I need to move to the next file. I am trying the code below but it seems to open the file and I do not want to open a file but just see if it is already open. Can someone tell me what I am using incorrectly? Also the code below does not seem to close the file, but keeps it open. Thanks in advance.

Dim fs As System.IO.FileStream
Try

fs = Files.open(Files.Filename, System.IO.FileMode.Open)
fs.Close()
Catch ex As Exception
Files.FindNext()
End Try
 
Back
Top