Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creting a directory....

Status
Not open for further replies.

buccaneer

Programmer
Joined
Feb 15, 2005
Messages
5
Location
GB
Hi

can anyone tell me the syntax to create a new directry on my c drive.

I've tried Dim di
Set di=Directory.CreateDirectory("C:\mydir")
and i get an error...
Object Required: 'Directory'
 
Take a look at the FileSystemObject (aka fso) for its FolderExists and CreateFolder methods:
Set fso = CreateObject("Scripting.FileSystemObject")
myDir = "C:\mydir"
If Not fso.FolderExists(myDir) Then
fso.CreateFolder(myDir)
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Code:
Dim strFolder
Dim objFSO

strFolder = "C:\myDir"

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CreateFolder(strFolder)
Set objFSO = Nothing

Tony
_______________________________________________________________
 
PHM - Top Man....sorted......

Am just learning so i will prob need more help :)

Does anyone know where there are examples of code i can look at or any good documentation...

cheers

Chris
 
In the FAQ area (for code and for doc pointers)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top