[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

get path without letter drive.

Posted on 2010-08-31
9
Medium Priority
?
531 Views
Last Modified: 2012-05-10
Hello,
is there a method in vb.net that returns a path, passed as argument that , without the letter drive?
0
Comment
Question by:arcross
[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
  • 2
  • 2
  • 2
  • +3
9 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 33566978
Can you give an example of what you want !
0
 
LVL 8

Author Comment

by:arcross
ID: 33567031
From the path:

c:\test1\test2\test3\file1.txt  id like to get it without the drive letter and filename

\test1\test2\test3\
0
 
LVL 5

Expert Comment

by:talkinsmak
ID: 33567048
So what you are looking for is the UNC path.
This is formatted like this:
\\servername\folder1\folder2\file.txt
Hope that helps.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33567154
try this
 Me.Label1.Text = Application.StartupPath
        Me.Label1.Text = Me.Label1.Text.Replace(Me.Label1.Text.Substring(0, 2), "")
    End Sub
0
 
LVL 1

Expert Comment

by:Jacob_Iedema
ID: 33567167
Assuming then you are not talking about a network path, i'm not aware of a method who will do this. However, you can do something like this:


        Label1.Text = Path.GetDirectoryName("C:\temp\somefile.msi")

        Dim var() As String = Split(Label1.Text, ":")
        Label2.Text = var(1).ToString

label2 gives you "\temp"
0
 
LVL 17

Expert Comment

by:Zhaolai
ID: 33567188
Try this:

        Dim strFile As String = "c:\test1\test2\test3\file1.txt "
        Dim oFile As System.IO.FileInfo = My.Computer.FileSystem.GetFileInfo(strFile)
        Dim strPath As String = oFile.Directory.FullName.Replace(oFile.Directory.Root.ToString, "") & "\"

Open in new window

0
 
LVL 17

Accepted Solution

by:
Zhaolai earned 2000 total points
ID: 33567216
Oh, need to add the leading \,

        Dim strFile As String = "c:\test1\test2\test3\file1.txt "
        Dim oFile As System.IO.FileInfo = My.Computer.FileSystem.GetFileInfo(strFile)
        Dim strPath As String = "\" & oFile.Directory.FullName.Replace(oFile.Directory.Root.ToString, "") & "\"

Open in new window

0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
ID: 33567242
Dim fi As New FileInfo ("C:\Temp\MyFile.txt")
Console.WriteLine (fi.DirectoryName.Tostring.Replace(fi.DirectoryName.Tostring.Substring(0, 2), ""))
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 33594046
I think that the solution is provided. Don't forget to close this question !
0

Featured Post

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.

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 …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

650 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