|
|
|
|
|
You are here...
VBScript - Check Whether a Folder Exists or Not
We can check whether a folder is existsing in the file system or not, using a function
'FolderExists' in the file system Object. This function takes an argument which is the
name of the Folder with the complete path and will return a boolean
value. 'True' means the folder Exists; 'False' means the folder doesn't Exist.
The syntax of the 'FolderExists' function is as follows
Syntax:
FolderExists(foldername)
'folderame': Here the argument foldername is the name of the folder with complete path.
The following code demonstrates how to check the existance of a folder.
Check Whether a Folder Exists or Not
Dim ObjFso
Dim StrFolderName
Dim BoolResult
StrFolderName = "C:\TestFolder"
Set ObjFso = CreateObject("Scripting.FileSystemObject")
BoolResult = ObjFso.FolderExists(StrFolderName)
If BoolResult = True Then
WScript.Echo("The Folder exists.")
Else
WScript.Echo("The Folder doesn't exist!!")
End If
|
|