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
If FSO.FileExists(strFile) Then
FileExists=true
FileExists = True
Else
else
FileExists=false
FileExists = False
End If
end if
End Function
end function

Function folderExists(strFolder)
Function FolderExists(strFolder)
if FSO.folderExists(strFolder) then
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)'''''
'''''Usage (apostrophes indicate comments-this section will not be run)'''''
'if fileExists("C:\test.txt") then
'If FileExists("C:\test.txt") Then
'msgbox"It Exists!"
' MsgBox "It Exists!"
'Else
'else
'msgbox"awww"
' Msgbox "awww"
'end if
'End If
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''



'Shortest version
'Shorter version


If CreateObject("Scripting.FileSystemObject").FileExists("d:\test.txt") Then
If CreateObject("Scripting.FileSystemObject").FileExists("d:\test.txt") Then