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

create folder - HELP!!!!!!!!

Status
Not open for further replies.

trmendonca

Programmer
Nov 5, 2003
2
0
0
PT
Hi,

I´m using vbscript, and the problem is if i put in the
script
fs.CreateFolder(""c:\test"), the folder was created.
If i put
fs.CreateFolder(""c:\Program Files\xpto\123\client\") i
had an error "path not found".

He only creates one directory in c:, but doesn´t create
the subdirectories.

What can i do?
Anyone can give a simple example to do this?

Please help, it´s URGENT

Best Regards


 
Easy...

Code:
MsgBox "Folder created:" & CreateFolder("C:\Program Files\xpto1\123\client")

Function CreateFolder(folderName)

	On Error Resume Next            
            
	Dim aFolders: aFolders = Split(folderName,"\")
	Dim i
	Dim currentFolder
	Dim oFSO: Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
	
	For i = LBound(aFolders) to UBound(aFolders)
		currentFolder = currentFolder & aFolders(i) & "\"
		If NOT oFSO.FolderExists(currentFolder) Then
			oFSO.CreateFolder(currentFolder)
		End If
	Next  'i            
	
	If oFSO.FolderExists(folderName) Then
		CreateFolder = True
	Else
		CreateFolder = False
	End If
	
End Function

HtH,

Rob
robschultz@yahoo.com
-Focus on the solution to the problem, not the obstacles in the way.-
 
I have used this method:

Dim strDestinPath

strDestinPath = "c:\Program Files\xpto\123\client"

'Create directory and copy files
If CheckFolder(strDestinPath) = False Then FSO.CreateFolder(strDestinPath)

Function CheckFolder(Folder)
CheckFolder = FSO.FolderExists(Folder)
End Function

HTH,

krameje
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top