Solved

get path without letter drive.

Posted on 2010-08-31
9
502 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
  • 2
  • 2
  • 2
  • +3
9 Comments
 
LVL 53

Expert Comment

by:Dhaest
Comment Utility
Can you give an example of what you want !
0
 
LVL 8

Author Comment

by:arcross
Comment Utility
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
Comment Utility
So what you are looking for is the UNC path.
This is formatted like this:
\\servername\folder1\folder2\file.txt
Hope that helps.
0
 
LVL 18

Expert Comment

by:John (Yiannis) Toutountzoglou
Comment Utility
try this
 Me.Label1.Text = Application.StartupPath
        Me.Label1.Text = Me.Label1.Text.Replace(Me.Label1.Text.Substring(0, 2), "")
    End Sub
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Expert Comment

by:Jacob_Iedema
Comment Utility
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
Comment Utility
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 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
I think that the solution is provided. Don't forget to close this question !
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now