RosettaCodeData/Task/Check-that-file-exists/VBScript/check-that-file-exists.vb

34 lines
782 B
VB.net
Raw Permalink Normal View History

2018-06-22 20:57:24 +00:00
Set FSO = CreateObject("Scripting.FileSystemObject")
2013-04-10 22:43:41 -07:00
Function FileExists(strFile)
2018-06-22 20:57:24 +00:00
If FSO.FileExists(strFile) Then
FileExists = True
Else
FileExists = False
End If
End Function
Function FolderExists(strFolder)
If FSO.FolderExists(strFolder) Then
FolderExists = True
Else
Folderexists = False
End If
End Function
'''''Usage (apostrophes indicate comments-this section will not be run)'''''
'If FileExists("C:\test.txt") Then
' MsgBox "It Exists!"
'Else
' Msgbox "awww"
'End If
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
2013-04-10 22:43:41 -07:00
2018-06-22 20:57:24 +00:00
'Shorter version
2013-04-10 22:43:41 -07:00
2018-06-22 20:57:24 +00:00
If CreateObject("Scripting.FileSystemObject").FileExists("d:\test.txt") Then
Wscript.Echo "File Exists"
Else
Wscript.Echo "File Does Not Exist")
End If