|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
create directory using UNC pathI am having difficulty with achieving the following: I have a UNC path, say \\machine\dir1\dir2\dir3 I want to: 1. check if it exists 2. if not, create it. The first thing is not a prob, but I am having problems with the second. I have looked in to MkDir (which I was advised to avoid using) and tried using the FileSystemObject without success. I already have a routine that creates (nested) folders for me, that uses the CreateDirectory API, but it cant handle UNC paths. Any input is appreciated, kind regards, arno Funny thing... I just created this for myself last week! It utilizes
the FSO, so you'll need a reference to Windows Script Host Object model. Public Sub CreateFolder(FolderPath As String) Dim fso As IWshRuntimeLibrary.FileSystemObject Set fso = New IWshRuntimeLibrary.FileSystemObject If Not fso.FolderExists(FolderPath) Then If Not fso.FolderExists(fso.GetParentFolderName(FolderPath)) Then CreateFolder fso.GetParentFolderName(FolderPath) End If End If fso.CreateFolder FolderPath Set fso = Nothing End Sub Jay Taplin [MCP - VB] Thanks Jay, your code does do the trick. However, as you say, it
requires a reference to the scripting host. I would like to not include that dependency. Any pointers as to how to go about? kind regards, arno On 30 Jan 2006 10:32:35 -0800, "Jay Taplin" <jaytap***@integraware.com> wrote: Show quoteHide quote >Funny thing... I just created this for myself last week! It utilizes >the FSO, so you'll need a reference to Windows Script Host Object >model.
Show quote
Hide quote
"arno" <rNOSPAMnospam@xs4all.nl> wrote in message Declare Function MakeSureDirectoryPathExists Lib "imagehlp.dll" (ByVal news:45dst119v64r3q5e9k5p7pr10hi3okf45u@4ax.com... > Hi, > > I am having difficulty with achieving the following: > > I have a UNC path, say \\machine\dir1\dir2\dir3 > > I want to: > 1. check if it exists > 2. if not, create it. > > The first thing is not a prob, but I am having problems with the > second. I have looked in to MkDir (which I was advised to avoid using) > and tried using the FileSystemObject without success. I already have a > routine that creates (nested) folders for me, that uses the > CreateDirectory API, but it cant handle UNC paths. > > Any input is appreciated, > > kind regards, > arno lpPath As String) As Long
How to best resize a form?
Using Control Array in User Control Proper way to resize a Form Why Randomize() won't work? [function LOF] Fails after WordPad saving VB6---.NET Passing data from a dll to the main VB program Problems with vbCtrlMask can't use a function from dll built in delphi VB crash on .PopupMenu .zmnuDemo Defaultmenu |
|||||||||||||||||||||||