• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 536
  • Last Modified:

get path without letter drive.

Hello,
is there a method in vb.net that returns a path, passed as argument that , without the letter drive?
0
arcross
Asked:
arcross
  • 2
  • 2
  • 2
  • +3
1 Solution
 
DhaestCommented:
Can you give an example of what you want !
0
 
arcrossAuthor Commented:
From the path:

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

\test1\test2\test3\
0
 
talkinsmakCommented:
So what you are looking for is the UNC path.
This is formatted like this:
\\servername\folder1\folder2\file.txt
Hope that helps.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
John (Yiannis) ToutountzoglouInstructor Multiengine PilotCommented:
try this
 Me.Label1.Text = Application.StartupPath
        Me.Label1.Text = Me.Label1.Text.Replace(Me.Label1.Text.Substring(0, 2), "")
    End Sub
0
 
Jacob_IedemaCommented:
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
 
ZhaolaiCommented:
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
 
ZhaolaiCommented:
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
 
John (Yiannis) ToutountzoglouInstructor Multiengine PilotCommented:
Dim fi As New FileInfo ("C:\Temp\MyFile.txt")
Console.WriteLine (fi.DirectoryName.Tostring.Replace(fi.DirectoryName.Tostring.Substring(0, 2), ""))
0
 
DhaestCommented:
I think that the solution is provided. Don't forget to close this question !
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now