Home Blogs Library Forums Support Advertise
VB Script
 
A Basic Tutorial
File System Programing
 
VBScript and MS Excel
VBScript and MS Access
 
VBScript and MS Word
VBScript and MS Powerpoint
 
Windows Registry Programing
 
Windows Administration
 
Active Directory Programing
 
Miscellaneous Functions
 
You are here...
Home > Vb Script - Home > File System programing > Check Whether a Folder Exists or Not

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