lila.godel
December 13th, 2008, 09:26 PM
I am unable to get my vb.NET 2008 SP1 application to work properly with mapped network drives that can only be accessed over a VPN connection.
My program is executed by selecting one of 5 Send To shortcuts. Each shortcut points to my program with a different command line argument that corrisponds to the drive letter for one of 2 local partitions or one of three mapped networked drives. An example Send To shortcut target is "C:\bin\Path Duplicator.exe" O:
At execution the program retrives the drive letter passed via the command line argument in the Send To shortcut and and whatever file(s) and or folder(s) I right clicked on to get to the send to menu.
The path(s) of the right clicked items are modified to have the orginal drive letter changed to the command line argument to create a new destination path.
So if right clicked on D:\Media\Test.txt and selected the Send To shortcut named Drive O (Maintain Path) the program would modify D:\Media\Test.txt to O:\Media\Test.txt to create a new destination path.
The program is supposed to then run the code
'display a message and abort if the current target directory is invalid
If Not dirTargetDirectory.Exists Then
DisplayMessage(MsgBoxStyle.Critical, dirTargetdirectory.FullName & _
" is not a valid path. Path duplicator will only copy " & _
"your source files if the target path exists.", _
"Invalid Target Path")
dirTargetDirectory = Nothing
Exit Sub
End If
where dirTargetDirectory is a variable of type DirectoryInfo.
If the target path's drive letter corrisponds to a local partition or to a mapped network drive at a time when my VPN connection is not active the program works correctly.
However if the target path's drive letter corrisponds to a mapped drive letter which is listed in Explorer with a red X and showing as unvaible in a command prompt net use listing indicating a timeout even though my VPN connection is active it is a no go.
As soon as the program executes, dirTargetDirectory.Exists returns false even if the new destination path is an existing valid path (should only return false if the path in invalid). In order to get the program to work I have to access the mapped network drive in Windows Explorer to end the timeout.
So if my source path is D:\Media\Test.txt and the destination path is O:\Media\Test.txt and O:\ is showing with a red X in Windows explorer I must access O:\ in Windows Explorer to make the program work correctly.
Is there some code I can place in my program prior to the if statement block to mimic accessing the drive in Windows Explorer so that if it is a mapped network drive any timeout will be cleared?
My program is executed by selecting one of 5 Send To shortcuts. Each shortcut points to my program with a different command line argument that corrisponds to the drive letter for one of 2 local partitions or one of three mapped networked drives. An example Send To shortcut target is "C:\bin\Path Duplicator.exe" O:
At execution the program retrives the drive letter passed via the command line argument in the Send To shortcut and and whatever file(s) and or folder(s) I right clicked on to get to the send to menu.
The path(s) of the right clicked items are modified to have the orginal drive letter changed to the command line argument to create a new destination path.
So if right clicked on D:\Media\Test.txt and selected the Send To shortcut named Drive O (Maintain Path) the program would modify D:\Media\Test.txt to O:\Media\Test.txt to create a new destination path.
The program is supposed to then run the code
'display a message and abort if the current target directory is invalid
If Not dirTargetDirectory.Exists Then
DisplayMessage(MsgBoxStyle.Critical, dirTargetdirectory.FullName & _
" is not a valid path. Path duplicator will only copy " & _
"your source files if the target path exists.", _
"Invalid Target Path")
dirTargetDirectory = Nothing
Exit Sub
End If
where dirTargetDirectory is a variable of type DirectoryInfo.
If the target path's drive letter corrisponds to a local partition or to a mapped network drive at a time when my VPN connection is not active the program works correctly.
However if the target path's drive letter corrisponds to a mapped drive letter which is listed in Explorer with a red X and showing as unvaible in a command prompt net use listing indicating a timeout even though my VPN connection is active it is a no go.
As soon as the program executes, dirTargetDirectory.Exists returns false even if the new destination path is an existing valid path (should only return false if the path in invalid). In order to get the program to work I have to access the mapped network drive in Windows Explorer to end the timeout.
So if my source path is D:\Media\Test.txt and the destination path is O:\Media\Test.txt and O:\ is showing with a red X in Windows explorer I must access O:\ in Windows Explorer to make the program work correctly.
Is there some code I can place in my program prior to the if statement block to mimic accessing the drive in Windows Explorer so that if it is a mapped network drive any timeout will be cleared?