kiranboi
asked on
Changing a path to a UNC path
Hi all,
I have a text box in my app where the user can specify a datapath. However if they put in a mapped network drive I need something that will automatically change the contents of the text box to the full network path.
Can someone tell me how I can do this?
Thanks
I have a text box in my app where the user can specify a datapath. However if they put in a mapped network drive I need something that will automatically change the contents of the text box to the full network path.
Can someone tell me how I can do this?
Thanks
ASKER
sounds like it might work.
how do i do that tho?
how do i do that tho?
Dim ps As New Process
Dim psi As New ProcessStartInfo
With psi
.FileName="cmd"
.Arguments="/c net use " & strDrive ' Perhaps use TextBox1.Text.SubString(0, 2) for this
.UseShellExecute=False
.RedirectStandardOutput=Tr ue
.WindowStyle=ProcessWindow Style.Hidd en
End With
With ps
.StartInfo=psi
.Start()
.WaitForExit()
.Close
End With
Dim strResults=ps.StandardOutp ut.ReadToE nd.Split(v bNewLine)
strPath=strResults(1) 'I 'think' it's the first element anyway...if that doesn't work, let me know...
Dim psi As New ProcessStartInfo
With psi
.FileName="cmd"
.Arguments="/c net use " & strDrive ' Perhaps use TextBox1.Text.SubString(0,
.UseShellExecute=False
.RedirectStandardOutput=Tr
.WindowStyle=ProcessWindow
End With
With ps
.StartInfo=psi
.Start()
.WaitForExit()
.Close
End With
Dim strResults=ps.StandardOutp
strPath=strResults(1) 'I 'think' it's the first element anyway...if that doesn't work, let me know...
Correction this line...since it's an array...
Dim strResults()=ps.StandardOu tput.ReadT oEnd.Split (vbNewLine )
Dim strResults()=ps.StandardOu
Looks like the first element (strResults(1)) will hold:
Remote name \\server\share
So
TextBox2.Text=strResults(1 ).SubStrin g(strResul ts(1).Inde xOf("\"))
should do it...
Remote name \\server\share
So
TextBox2.Text=strResults(1
should do it...
ASKER
Ive tried that and the line
Dim strResults()=ps.StandardOu tput.ReadT oEnd.Split (vbNewLine )
is giving me the following error
StandardOut not started or the process hasnt started yet
Any ideas?
Dim strResults()=ps.StandardOu
is giving me the following error
StandardOut not started or the process hasnt started yet
Any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thats great thanx, thats exactly what i needed :)
Happy to help - thanx for the grade! :^)
I wonder if you could redirect the output of a net use 'drive letter' to get at it...