The issue is notepad will not lock the file.
You will need to check the process list and see if the file is currently opened.
{code}
Public Class TextFile
Sub RunIt()
MsgBox(isTextFileInUse("c:\test1.txt"))
End Sub
Function isTextFileInUse(ByVal FullPath As String) As Boolean
Dim FileName As String = ""
If Not isFileInUse(FullPath) Then
FileName = System.IO.Path.GetFileName(FullPath)
If CheckNotepad(FileName) Then
Return True
End If
Else
Return True
End If
Return False
End Function
Public Function isFileInUse(ByVal sFile As String) As Boolean
If System.IO.File.Exists(sFile) Then
Try
Dim F As Short = FreeFile()
FileOpen(F, sFile, OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.LockReadWrite)
FileClose(F)
Catch
Return True
End Try
End If
End Function
Function CheckNotepad(ByVal textFile As String) As Boolean
Dim ProcessList As System.Diagnostics.Process()
Dim Proc As System.Diagnostics.Process
Dim rtnValue As Boolean = False
ProcessList = System.Diagnostics.Process.GetProcesses()
Try
For Each Proc In ProcessList
If Proc.ProcessName.ToUpper = "NOTEPAD" Then
If Proc.MainWindowTitle.Substring(0, textFile.Length).ToUpper = textFile.ToUpper Then
rtnValue = True
Exit For
End If
End If
Next
Catch ex As Exception
End Try
Return rtnValue
End Function
End Class
{code}
---------------------------
(defun botsbuildbots() (botsbuildbots))