Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Changing a path to a UNC path

Posted on 2007-03-20
9
Medium Priority
?
253 Views
Last Modified: 2011-09-20
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
0
Comment
Question by:kiranboi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
9 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 18756086
Hmm - without knowing the server?

I wonder if you could redirect the output of a net use 'drive letter' to get at it...
0
 

Author Comment

by:kiranboi
ID: 18756143
sounds like it might work.
how do i do that tho?
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18756171
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=True
  .WindowStyle=ProcessWindowStyle.Hidden
End With
With ps
  .StartInfo=psi
  .Start()
  .WaitForExit()
  .Close
End With
Dim strResults=ps.StandardOutput.ReadToEnd.Split(vbNewLine)
strPath=strResults(1) 'I 'think' it's the first element anyway...if that doesn't work, let me know...


0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 67

Expert Comment

by:sirbounty
ID: 18756188
Correction this line...since it's an array...

Dim strResults()=ps.StandardOutput.ReadToEnd.Split(vbNewLine)
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18756203
Looks like the first element (strResults(1)) will hold:

Remote name     \\server\share

So
TextBox2.Text=strResults(1).SubString(strResults(1).IndexOf("\"))

should do it...
0
 

Author Comment

by:kiranboi
ID: 18756814
Ive tried that and the line
   Dim strResults()=ps.StandardOutput.ReadToEnd.Split(vbNewLine)
is giving me the following error
   StandardOut not started or the process hasnt started yet

Any ideas?
0
 
LVL 67

Accepted Solution

by:
sirbounty earned 2000 total points
ID: 18756931
Slight modification - and this one's tested...

Dim ps As New Process
Dim psi As New ProcessStartInfo
With psi
  .FileName="cmd"
  .Arguments="/c net use " & strDrive 'strDrive must have the colon (F:)
  .UseShellExecute=False
  .RedirectStandardOutput=True
  .WindowStyle=ProcessWindowStyle.Hidden
End With
With ps
  .StartInfo=psi
  .Start()
  .WaitForExit()
End With
Dim strResults()=ps.StandardOutput.ReadToEnd.Split(vbNewLine)
TextBox2.Text=strResults(1).SubString(strResults(1).IndexOf("\"))
0
 

Author Comment

by:kiranboi
ID: 18772254
thats great thanx, thats exactly what i needed :)
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18772275
Happy to help - thanx for the grade! :^)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question