CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2005
    Posts
    4

    DirectoryInfo.Exists & Unvailable Mapped Drive

    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

    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?
    Last edited by lila.godel; December 14th, 2008 at 11:18 AM.

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: DirectoryInfo.Exists & Unvailable Mapped Drive

    You can map the drives from within your app, but you probably don't have permissions to do so. That's why you see the red X.
    Code:
    NET USE X: \Delete
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jul 2005
    Posts
    4

    Re: DirectoryInfo.Exists & Unvailable Mapped Drive

    Quote Originally Posted by dglienna View Post
    You can map the drives from within your app, but you probably don't have permissions to do so. That's why you see the red X.
    Code:
    NET USE X: \Delete
    The drives are not being mapped in my application. They already mapped, but after a period of no access a time out happens and they are show as unvailable in a net use listing even after a VPN connecition is established. To get net use to show them as available and enable my program to see them as available I must click on them in Windows explorer.

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: DirectoryInfo.Exists & Unvailable Mapped Drive

    Sounds like Windows is turning off the device. That'd do it
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured