Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detect mapped drive

Status
Not open for further replies.

YerMom

Programmer
Oct 3, 2006
127
US
I have an app that displays a FolderBrowserDialog that allows users to select directories. I need to detect when a user selects a directory on a mapped drive.

Is this possible to do?

thanks.
 
If anyone is interested, I discovered a way to do this. You use the DriveInfo class as shown below.

Code:
Private Function IsFolderNetwork(ByVal path As String) As Boolean

        Dim root As String
        root = path.Substring(0, 3)
        Dim retVal As Boolean = False

        Dim allDrives() As System.IO.DriveInfo = System.IO.DriveInfo.GetDrives()


        Dim d As System.IO.DriveInfo
        For Each d In allDrives
            Console.WriteLine("Drive {0}", d.Name)
            Console.WriteLine("  File type: {0}", d.DriveType)
            If root.Equals(d.Name) And d.DriveType.ToString.Equals("Network") Then
                retVal = True
            End If
        Next

        Return retVal

    End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top