Code to check textfile exitst in a given directory or not
It will check whether textfile starts with letter 's' is present in d: directory or not
It will check whether textfile starts with letter 's' is present in d: directory or not
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
Dim RootPath As String = "D://"
Dim files As String()
files = Directory.GetFiles(RootPath, "s*.txt")
If (files.Length > 0) Then
MsgBox("Files Exists")
Else
MsgBox(" doesn't Exists")
End If
End Sub
Regards
Swathi
Following is the code to look for existence of a specific text file in a folder.
'
' folder is the name of folder where you are searching
' file is name of the file you are looking
sub find_file(byval folder as string, byval file as string)
Dim required_file as string=Directory.GetFiles(folder, file)
if required_file.length>0 then
Msgbox(file & "is found in the folder: " & folder)
else
Msgbox("No such file found in the folder" & folder)
end if
end sub