Tuesday, April 20, 2010

Creating a Folder in VB Script using FileSystemObject

Back To File System Object Page

How to create a Folder using VB script?

Using the File System Object method CreateFolder we create a Folder and Using the GetFolder Method we get the newly created Folder.


'Create a Folder using FSO or FileSystemObject

'Step 1: Create an object variable that interacts with the File System Object Library

Set Fso = CreateObject("Scripting.FileSystemObject")

'Step 2; Use the CreateFolder method along with the object to create a Folder at desired location

Fso.CreateFolder("F:\Test Folder")

'Step 3: Use the GetFolder method to get the newly created file and store in a variable called s

Set s = fso.GetFolder("F:\Test Folder")

'Step 4: Use the name method to get the file name and print it along with the message

Msgbox "The New Folder Created is "&s.name

Back To File System Object Page

No comments:

Post a Comment