Accessing File
Visual Basic
2
Posts
2
Posters
0
Views
1
Watching
-
Can anyone please give me a hint how to check whether a file i being accessed by another process or not, so that i can open it for manipulation. Thanks in advance!
AliAmjad(MCP) First make it Run THEN make it Run Fast!
Private Function isFileInUse(ByVal sFileName As String) As Boolean Dim nFileNum As Integer ' If the file is already opened by another process and the specified type of access ' is not allowed the Open operation fails and an error occurs. Try nFileNum = FileSystem.FreeFile() FileSystem.FileOpen(nFileNum, sFileName, OpenMode.Binary, OpenAccess.Read, OpenShare.LockReadWrite) FileSystem.FileClose(nFileNum) Catch Return True End Try Return False End Function
alex_nel