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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileSystemObject

Status
Not open for further replies.

jtseltmann

Programmer
Jan 15, 2002
149
US
Can anyone help me understand why the following is failing?
'---
Dim fso as object
Set fso = CreateObject("Scripting.FileSystemObject")
fso.CreateFolder "H:\data\temp"
'---
I get a 76 - path not found error every time

If I change the above code to run this it works...

fso.CreateFolder "H:\data"
fso.CreateFolder "H:\data\temp"

I don't understand why the first is failing. I'm trying to determine if a new server setting has caused this new error? Anyone have any thoughts?

Thanks.


 
I don't understand why the first is failing
Really ?
You don't understand that you can't create the temp subfolder in the non existing H:\data folder ?
A starting point:
Code:
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
myMkDir "H:\data\temp"

Sub myMkDir(strFolderName)
On Error Resume Next
Dim a, t, i
a = Split(strFolderName, "\")
t = a(0)
For i = 1 To UBound(a)
  t = t & "\" & a(i)
  fso.CreateFolder t
Next
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I guess a better way would be that I thought this code was working in other places and I have seen examples before where there was a complete path to a sub dir and I guess I mistook that for the above.

I can write a routine that loops through and does each but I thought that I had run this many times as a batch file would do and be able to create the directory at once. The equivalent "MD ... command in a batch file works just fine.

I don't truly need sarcasm...obviously I understand the logic but I have used other batch programming to do it in one swipe so I did not realize I was doing it...just some friendly advice/suggestions is all I was looking for.
 
just some friendly advice/suggestions is all I was looking for
did you try my suggestion ?
 
I didn't need to being that I knew how to get around it. As I said, I was just looking for confirmation that I was truly executing the code incorrectly. I got that confirmation and have the code I need working just fine. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top