IsNetworkDrive

This function returns a boolean value according to whether a drive is a network drive or not.

VB.NET

''' <summary>
''' Determines whether a drive is a network drive or not.
''' </summary>
''' <param name="driveLetter">The letter of the drive, e.g "c".</param>
''' <returns>True if the drive is a network drive, False otherwise.</returns>
''' <remarks></remarks>

Public Shared Function IsNetworkDrive(ByRef driveLetter As String) As Boolean
    Dim driveInfo As System.IO.DriveInfo, driveType As System.IO.DriveType
    driveInfo = My.Computer.FileSystem.GetDriveInfo(driveLetter)
    driveType = driveInfo.DriveType
    If driveType = IO.DriveType.Network Then Return True
    Return False
End Function

' How to call the function:
Dim boolNetworkDrive As Boolean = IsNetworkDrive("c")

See Also

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License