Pages

Showing posts with label create new file. Show all posts
Showing posts with label create new file. Show all posts

Saturday, June 2, 2012

How to create new file using FileSystemObject

Option Explicit
Dim objFSO, objFSOText, objFolder, objFile
Dim strDirectory, strFile
strDirectory = "C:\New Folder"
strFile = "\New File.txt"

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder(strDirectory)
Set objFile = objFSO.CreateTextFile(strDirectory & strFile)
Wscript.Echo strDirectory & strFile & " created successfully."
Wscript.Quit