From: Jason on 18 Mar 2010 09:09 Hello Is there a easy way to create the folder path c:\folder1\folder2\folder3 ?
From: Steve on 18 Mar 2010 09:47 Jason wrote: > > Is there a easy way to create the folder path > c:\folder1\folder2\folder3 ? Const FULL_PATH = "c:\folder1\folder2\folder3" Set fso = CreateObject("Scripting.FileSystemObject") BuildPath FULL_PATH Sub BuildPath(ByVal Path) If Not fso.FolderExists(Path) Then BuildPath fso.GetParentFolderName(Path) fso.CreateFolder Path End If End Sub -- Steve Courage is resistance to fear, mastery of fear-not absence of fear. -Mark Twain
From: LikeToCode on 18 Mar 2010 12:05 Or simply: Set objFSO = CreateObject("scripting.filesystemobject") objFSO.CreateFolder("c:\folder1\folder2\folder3") This uses the CreateFolder Method of FileSystemObject. More information can be found here: http://msdn.microsoft.com/en-us/library/6tkce7xa(VS.85).aspx and http://msdn.microsoft.com/en-us/library/7kby5ae3(VS.85).aspx
From: ekkehard.horner on 18 Mar 2010 16:38 LikeToCode schrieb: > Or simply: > > Set objFSO = CreateObject("scripting.filesystemobject") > objFSO.CreateFolder("c:\folder1\folder2\folder3") > > This uses the CreateFolder Method of FileSystemObject. More information can > be found here: > http://msdn.microsoft.com/en-us/library/6tkce7xa(VS.85).aspx > > and > > http://msdn.microsoft.com/en-us/library/7kby5ae3(VS.85).aspx > For VBScript 5.6 and 5.7 .CreateFolder won't create a folder unless its parent folder exists. I would like to know, whether newer versions of VBScript (FSO) are more programmer friendly. To be on the save side, you should use a recursive sub like Steve's or shell out for mkdir.
From: LikeToCode on 18 Mar 2010 18:36 On my win7 box it is the same, this shows you how often I need to create complete folder paths. ;-) You can still accomplish this with 2 lines of code. Set objShell = CreateObject("Wscript.Shell") objShell.Run "cmd /c mkdir C:\folder1\folder2\folder3"
|
Pages: 1 Prev: Diff in running VBScripts-WMI routuines from WinTaskSch & SQL Agen Next: Split Method |