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!

creating a directory....

Status
Not open for further replies.

buccaneer

Programmer
Joined
Feb 15, 2005
Messages
5
Location
GB
Hi, i'm new to this game and am trying to create directories in a script... i used the code below but it dont work....any ideas ??


' Try to create the directory.
Dim di 'As DirectoryInfo = Directory.CreateDirectory("C:\mydir")

cheers chris
 
Well, first you need to remove the apostrophe before the "As" that is commenting out the variable definition:

Dim di As DirectoryInfo = Directory.CreateDirectory("C:\mydir")

Second, are you getting any error messages? If so, what?

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
If i remove the apostrophe i get a Windows Script Host error.

Line 1 Char 8
Error : Expected end of statement
Code 800A0401
Source : Microsoft VBScript compilation error

 
Code:
dim directory as FileSystemObject
dim di
set directory = createobject("Scripting.FileSystemobject")
set di = directory.createfolder("c:\mydir")
 
Dim AS in Script?
1.) This is VB6 forum, not VBScript forum329
;-)

2.) In the latter case, try
Code:
Dim di
Set di=Directory.CreateDirectory("C:\mydir")

Hope this helps.

Cheers,
Andy

[blue]An eye for an eye only ends up making the whole world blind. - "Mahatma" Mohandas K. Gandhi[/blue]
Check out this:
 
MakeItSo

when i try your way i get an error on line 2

Object required : 'Directory'
code 800A01A8

am i in the wrong forum ??
whats the difference between VBscript and VB6 ?

 
Several commands don't exist in Script.
I see PHV referred you to the FileSystemObject in the Script forum, which is better.
I have never used the Directory object before and I've heard, it was kind of buggy anyway...

Major difference between VB and VBScript:
In VBScript you don't dimension variables as a certain type, just Dim them.

String operations like Mid or Mid$ don't exist in VBScript, you need to work around with left and right functions.
Here are two official comparison lists:



Hope this helps.

Regards,
Andy


[blue]An eye for an eye only ends up making the whole world blind. - "Mahatma" Mohandas K. Gandhi[/blue]
Check out this:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top