VBScript » FileSystemObject » FolderExists

Version: 2.0

Syntax:
object.FolderExists(folder)
(folder)

Allows us to check if a specified folder exists. Returns True if the folder does exist and False if it doesn't.

Note that if the folder that you are checking for isn't a subfolder of the current folder, you must supply the complete path.

Examples

Code:
<%
dim filesys, newfolder
set filesys=CreateObject("Scripting.FileSystemObject")
If Not filesys.FolderExists("c:\DevGuru\website\") Then
newfolder = filesys.CreateFolder ("c:\DevGuru\website\")
Response.Write ("A new folder '" newfolder "' has been created")
End If
%>
Output:
"A new folder 'c:\DevGuru\website\' has been created."
Explanation:

In this example the FolderExists method is used before creating a new folder to check that it doesn't already exist.

Language(s): VBScript