Check that file exists: Difference between revisions
Content added Content deleted
m (→{{header|VBScript}}: indentation - but these If/Then are totally useless, and so are these functions: calling FSO.FileExists(name) is equivalent to this FileExists(name)) |
|||
Line 2,220: | Line 2,220: | ||
=={{header|VBScript}}== |
=={{header|VBScript}}== |
||
<lang vbscript>Set FSO=CreateObject("Scripting.FileSystemObject") |
<lang vbscript>Set FSO = CreateObject("Scripting.FileSystemObject") |
||
Function FileExists(strFile) |
Function FileExists(strFile) |
||
If FSO.FileExists(strFile) Then |
|||
FileExists= |
FileExists = True |
||
Else |
|||
else |
|||
FileExists= |
FileExists = False |
||
End If |
|||
end if |
|||
End Function |
|||
end function |
|||
Function |
Function FolderExists(strFolder) |
||
If FSO.FolderExists(strFolder) Then |
|||
FolderExists = True |
|||
folderExists=true |
|||
Else |
|||
else |
|||
Folderexists = False |
|||
folderexists=false |
|||
End If |
|||
end if |
|||
End Function |
|||
end function |
|||
''''' |
'''''Usage (apostrophes indicate comments-this section will not be run)''''' |
||
' |
'If FileExists("C:\test.txt") Then |
||
' |
' MsgBox "It Exists!" |
||
'Else |
|||
'else |
|||
' |
' Msgbox "awww" |
||
' |
'End If |
||
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' |
|||
' |
'Shorter version |
||
If CreateObject("Scripting.FileSystemObject").FileExists("d:\test.txt") Then |
If CreateObject("Scripting.FileSystemObject").FileExists("d:\test.txt") Then |