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

FSO.CreateFolder permission error 1

Status
Not open for further replies.

developer155

Programmer
Jan 21, 2004
512
US
Hi, I am using FSO to create a folder on our image server and VB gives me an error (for some reason no description). I used the same code (CreateFolder) to create a folder on my PC and it worked just fine, so I am thinking it is some kind of a permission problem when VB runs on my IDE and tries to create a folder on image server. The only thing I do not understand is that I can go to that directory on the image server and manually create a folder (just like I am trying to create with FSO). Does anyone know why is that?


thanks
 
Does the folder already exist by some chance? Also, it does not give you an error description? Another method you can use instead of FSO would be to do something like this:

If Dir$("C:\Test\", vbDirectory) <> vbNullString Then
MsgBox "Folder Already Exists!", vbInformation
Else
MkDir "C:\Test\"
End If

Swi
 
thanks Swi. The error is actually File not Found... Not sure what that means in this context. And no, the folder does nto exist, I check before.. (I also tried your methods). Not sure whats going on, will keep investigating
 
Can you post the code so we can take a look at it?

Swi
 
Dim fsoFile As FileSystemObject
Set fsoFile = CreateObject("scripting.filesystemobject")

On Error GoTo errHandler

With fsoFile
If Not .FolderExists(gudFileInfo.szLocalImageDir & CStr(m_lTracknum)) Then
Call .CreateFolder(gudFileInfo.szLocalImageDir & CStr(m_lTracknum))
End If
'
Call .CreateFolder("C:\testFolder\10205644\11001\") 'this works fine!

'this is your code....
If Dir$(szTargetDir, vbDirectory) <> vbNullString Then
MsgBox "Folder Already Exists!", vbInformation
Else
MkDir szTargetDir
End If

'this is what I had before, both give the same error on
'Call .CreateFolder(szTargetDir)

If Not .FolderExists(szTargetDir) Then
Call .CreateFolder(szTargetDir)
End If
 
You must generate the root folder and then add the subfolders. I am working on a solution now and will post in a few moments.

Swi
 
I just wanted to say that I had no problem creating the folder from command prompt using mkdir
 
Private Sub NestedFolder(FullPathName As String)
Dim myarr() As String
Dim x As Long
Dim TempFullPath As String
myarr = Split(FullPathName, "\")
For x = 0 To UBound(myarr)
FullPath = FullPath & myarr(x) & "\"
If Dir$(FullPath, vbDirectory) = vbNullString Then MkDir FullPath
Next
End Sub

Private Sub Command1_Click()
Dim FolderToCreate As String
FolderToCreate = "C:\testFolder\10205644\11001\"
If Dir$(FolderToCreate, vbDirectory) = vbNullString Then
NestedFolder "C:\testFolder\10205644\11001\"
Else
MsgBox "Folder already exists!", vbCritical
End If
End Sub


Swi
 
actaually my file to create is something like this

\\imageservername\images\NewFolder\NewSubFolder

Nested Folder gives error when going through the array (I am guessing because of \\)

thx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top