mkdir and UNC path

J

JamesSF

I want to make a directory on a networked computer using the UNC path.

i tried using both
Set fs = CreateObject("Scripting.FileSystemObject")
Set g = fs.CreateFolder("\\Conferencexp\c$\070103\test\070103\")


MkDir \\Conferencexp\c$\070103\test\070103\

neither of these work.

they also dont work if i use MkDir c:\070103\test\070103

by default, MkDir 070103 goes to my documents.

any ideas?

Thanks
JamesSF
 
D

Douglas J. Steele

To be honest, I don't remember whether MkDir works with UNCs, and
unfortunately I can't test at the moment.

However, do subfolders 070103 and test both exist? MkDir is only capable of
creating one level of folder at a time.
 
J

John Spencer (MVP)

Also, I believe that the path has to be a string.

MkDir "c:\070103\test\070103"

I believe that MkDir does not support UNCs.
 
J

JamesSF

ok thanks

so at this time, we cant create folders on a networked drive - hmmm

and cant create multiple directories deep at once?

is there a old dos command to copy tree structure? (ie no data)

thanks
 
G

Geoff

Could you map the network drive to a drive letter,
then work on the drive letter?

Sorry I don't know how to use vb to map a
network drive programmatically.

The Split function is handy to chop up a path
into its folders (which have to be created one
at a time if they don't exist.)

Regards
Geoff
 
G

Geoff

Here's an example:

Sub CreatePath()

Const strMakeThisPath As String = "C:\Data\JamesSF\Access\Workcopy"

Dim aryFolders() As String
Dim strFolder As String
Dim intCounter

' Chop up path and create array of folders:
aryFolders = Split(strMakeThisPath, "\")

' Make the folders one at a time:
For intCounter = 0 To UBound(aryFolders)
If intCounter = 0 Then
' Concatenate drive letter and first folder:
strFolder = aryFolders(intCounter)
intCounter = intCounter + 1
strFolder = strFolder & "\" & aryFolders(intCounter)
CreateFolder strFolder
Else
' Process other folders:
strFolder = strFolder & "\" & aryFolders(intCounter)
CreateFolder strFolder
End If
Next
Erase aryFolders

End Sub

Sub CreateFolder(strFolderName As String)
If Dir(strFolderName, vbDirectory) = "" Then
MkDir strFolderName
End If
End Sub


Regards
Geoff
 
D

Douglas J. Steele

I don't believe DOS allows the copy of tree structures: as far as I recall,
you've always had to create nested folders one folder at a time.

You can create folders on a networked drive. You just need to map the drive
first. I don't see that as being too onerous a restriction.

As to nested subdirectories, Randy Birch shows a couple of approaches at
http://www.mvps.org/vbnet/code/file/nested.htm

You need to be careful with many of the samples from Randy's site: it's
aimed at VB programmers, so often the form-related instructions don't port
to Access. I took a quick look at this one, though, and I think it should
work in Access without any changes.
 
J

Jose Hernandez

Do you have permissions to create folders?

The following worked for me(\\supply\c$\TEMP\ exists)

MkDir "\\supply\c$\TEMP\Jose\"

To create multiple directories at once you can use this API
'-------------- START CODE -----------------------------
'Requirements:
' Windows NT/2000/XP: Included in Windows 2000 and later.
' Redistributable: Requires DbgHelp.dll 5.0 or later on Windows NT 4.0 and
Windows 95/98/Me.
' Header: Declared in Dbghelp.h.
' Library: Use Dbghelp.lib.
Public Declare Function MakeSureDirectoryPathExists Lib "Imagehlp.dll"
(ByVal DirPath As String) As Long
'-------------- END CODE -----------------------------
Example (\\supply\c$\TEMP\ exists)
?MakeSureDirectoryPathExists("\\supply\c$\TEMP\Jose\2003\10\")

HTH

Jose
 
J

JamesSF

From a command prompt

xcopy <FROM> <DESTINATION> /T /E

copies directory structure including empty folders without copying files.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top