I have two snippets of code that work just fine locally but seem to have issues when run over the network.
When I run the code from within my LAN, it captures a directory location (Path), checks to see if that location exists, and if it doesn't, then make the correct directory tree. The location is on a network drive.
I have simplified the code below.
However, if I remote into my network via Citrix, the "R:" no longer exists under that drive letter. It now follows the Universal Naming convention for networked drives.
So I changed the code to make it work for when I remote in. The only code that changed is the Path name.
If the folder path already exists, no issues.
The problem comes specifically from the "MkDir strPath" code when using the Universal Naming convention. It fails and debugs. It can't make the directory using the \\Network\Drive\Name\ ....." for some reason.
I can't determine if it is a permissions thing when accessing the drive remotely, if I coded it incorrectly, etc.
Any ideas on what needs to change to make it work? Are there any alternatives or different ways to have a directory created other than MkDir??
Your guidance is very much appreciated!!
-Spydey
When I run the code from within my LAN, it captures a directory location (Path), checks to see if that location exists, and if it doesn't, then make the correct directory tree. The location is on a network drive.
I have simplified the code below.
Code:
Sub start()
Dim Path As String
Path = "R:\Location\Of\The\Folder\Where\The\File\Needs\To\Be\Saved\"
Call MakeDirectory(Path)
End Sub
Sub MakeDirectory(FolderPath As String)
Dim x, i As Integer, strPath As String
x = Split(FolderPath, "\")
For i = 0 To UBound(x) - 1
strPath = strPath & x(i) & "\"
If Not FolderExists(strPath) Then MkDir strPath
Next i
End Sub
Function FolderExists(FolderPath As String) As Boolean
On Error Resume Next
ChDir FolderPath
If Err Then FolderExists = False Else FolderExists = True
End Function
However, if I remote into my network via Citrix, the "R:" no longer exists under that drive letter. It now follows the Universal Naming convention for networked drives.
So I changed the code to make it work for when I remote in. The only code that changed is the Path name.
Code:
Sub start()
Dim Path As String
Path = "\\Network\Drive\Name\Location\Of\The\Folder\Where\The\File\Needs\To\Be\Saved\"
Call MakeDirectory(Path)
End Sub
Sub MakeDirectory(FolderPath As String)
Dim x, i As Integer, strPath As String
x = Split(FolderPath, "\")
For i = 0 To UBound(x) - 1
strPath = strPath & x(i) & "\"
If Not FolderExists(strPath) Then MkDir strPath
Next i
End Sub
Function FolderExists(FolderPath As String) As Boolean
On Error Resume Next
ChDir FolderPath
If Err Then FolderExists = False Else FolderExists = True
End Function
If the folder path already exists, no issues.
The problem comes specifically from the "MkDir strPath" code when using the Universal Naming convention. It fails and debugs. It can't make the directory using the \\Network\Drive\Name\ ....." for some reason.
I can't determine if it is a permissions thing when accessing the drive remotely, if I coded it incorrectly, etc.
Any ideas on what needs to change to make it work? Are there any alternatives or different ways to have a directory created other than MkDir??
Your guidance is very much appreciated!!
-Spydey
Last edited: