断开映射驱动器vb

时间:2013-11-07 17:58:29

标签: vb.net webdav disconnect mapped-drive

我使用找到下一个可用字母驱动器的函数映射了网络驱动器,然后使用net use z:\ server \ z映射它,如何断开所有网络驱动器而不仅仅是z?感谢您的任何帮助 。附:我是这一切的新手:)

    Dim alphabet As New System.Collections.Specialized.StringCollection()


    Dim lowerBound As Integer = Convert.ToInt16("g"c)
    Dim upperBound As Integer = Convert.ToInt16("z"c)
    For i As Integer = lowerBound To upperBound - 1
        Dim driveLetter As Char = ChrW(i)
        alphabet.Add(driveLetter.ToString())
    Next

    lowerBound = Convert.ToInt16("a"c)
    upperBound = Convert.ToInt16("i"c)
    For i As Integer = lowerBound To upperBound - 1
        Dim driveLetter As Char = ChrW(i)
        alphabet.Add(driveLetter.ToString())
    Next

    ' get all current drives
    Dim drives As System.IO.DriveInfo() = System.IO.DriveInfo.GetDrives()
    For Each drive As System.IO.DriveInfo In drives
        alphabet.Remove(drive.Name.Substring(0, 1).ToLower())
    Next

    For Each s As String In alphabet
        If System.IO.Directory.Exists(s) = False Then
            Return s
        End If
    Next

1 个答案:

答案 0 :(得分:1)

net use z: \\server\z /delete 

我确定有一个比这更好的网站,但这个工作:Net Use