check connection sharing network folder using username and password

712 views Asked by At

In my application check network folder connection using following code

Dim myIP As IPHostEntry = Dns.GetHostEntry(txtNetworkDrive.Text.Trim.Split("\", options:=StringSplitOptions.RemoveEmptyEntries)(0))
            Dim IPAddress As String = myIP.AddressList.GetValue(0).ToString


            Dim xStr As New System.Security.SecureString
            For Each c As Char In txtNetworkPassword.Text.Trim
                xStr.AppendChar(c)
            Next

            Dim psi As New ProcessStartInfo()

            psi.UserName = txtNetworkusername.text
            psi.Password = xStr
            psi.Domain = IPAddress 
            psi.FileName = txtNetworkDrive.Text
            psi.UseShellExecute = False
            Process.Start(psi)

The Input like

Network drive = "\\Sys4\shareddocs"

Network password= "sys4"
Network Username="user"
IPaddress="198.168.0.24"

But all time it show login failure bad username and password. what am doing wrong? How get the solutions?

0

There are 0 answers