hendrikbez
Active member
have this code, with button click it must, map dirve, do getinfo and then disconnect.
It only map and getinfo, but it does not disconnect from server, what and were is the problem.
It only map and getinfo, but it does not disconnect from server, what and were is the problem.
VB.NET:
Private Sub test_ClickButtonArea(ByVal Sender As System.Object, ByVal e As System.EventArgs) Handles test.ClickButtonArea
' Map Drive
Dim user As String = "justme"
Dim passWrd As String = "tooneand"
Dim driveLtr As String = "R"
Dim pathName As String = "\\11.105.52.121\c$"
If MapDrive(driveLtr, pathName, user, passWrd) = True Then
MessageBox.Show("Norton C: is Maped as R:")
Else
MessageBox.Show("Drive is already Maped")
End If
'drive name or folder path
Dim DriveC As String = "R:"
Dim msg As String = ""
Dim FreeBytesAvailableToMe As Long 'the available free bytes to the user whose process this is
Dim TotalBytes As Long 'the total available bytes to the user whose process this is
Dim FreeBytes As Long 'the total number of free bytes on a <SPAN class=searchlite>disk</SPAN>
Dim FetchResult As Integer
'the function returns non zero if successful and 0 if failed
FetchResult = GetDiskFreeSpaceEx(DriveC, FreeBytesAvailableToMe, TotalBytes, FreeBytes)
If FetchResult <> 0 Then
Dim bytes As String = Format(FreeBytes, "###,###,##") & " Bytes Free"
Dim MBytes As Double
MBytes = (FreeBytes \ 1024) \ 1024
msg = msg & "Norton"
msg = msg & ControlChars.NewLine
MessageBox.Show(msg)
Else
MessageBox.Show("Drive not available or folder not accessible")
End If
End Sub
Public Function UnMapDrive(ByVal DriveLetter As String) As Boolean
Dim rc As Integer
rc = WNetCancelConnection2(DriveLetter & ":", 0, ForceDisconnect)
If rc = 0 Then
Return True
Else
Return False
End If
End Function
Last edited by a moderator: