Parsing text files

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Justin Fancy

    #1

    Parsing text files

    Hi Everyone,

    I am creating a vb.net application, and i'm almost done. Except for one
    problem. I need to be able to change this output:

    C:\Documents and Settings\fancyj \My Documents\Visua l Studio
    Projects\FileDi fferencing\bin\ Comparison.ldb

    into a format that is in another file:

    /VisualStudioPro jects/FileDifferencin g/bin/Comparison.ldb

    So, basically I want to cut the leading folders and include only the
    subfolder off of the root.

    Any suggestions?

  • Tim Patrick

    #2
    Re: Parsing text files

    If the start of the path is the official My Documents folder for the user,
    you could try something like this.

    Dim sourcePath As String
    Dim destPath As String

    sourcePath = "C:\Documen ts and Settings\fancyj \My Documents\Visua l
    Studio Projects\FileDi fferencing\bin\ Comparison.ldb"
    destPath = Replace(sourceP ath, My.Computer.Fil eSystem.Special Directories.MyD ocuments,
    "")
    destPath = Replace(destPat h, "\", "/")

    -----
    Tim Patrick
    Start-to-Finish Visual Basic 2005
    C:\Documents and Settings\fancyj \My Documents\Visua l Studio
    Projects\FileDi fferencing\bin\ Comparison.ldb
    >
    into a format that is in another file:
    >
    /VisualStudioPro jects/FileDifferencin g/bin/Comparison.ldb
    >

    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: Parsing text files

      "Justin Fancy" <justinfancy@gm ail.comschrieb:
      I am creating a vb.net application, and i'm almost done. Except for one
      problem. I need to be able to change this output:
      >
      C:\Documents and Settings\fancyj \My Documents\Visua l Studio
      Projects\FileDi fferencing\bin\ Comparison.ldb
      >
      into a format that is in another file:
      >
      /VisualStudioPro jects/FileDifferencin g/bin/Comparison.ldb
      >
      So, basically I want to cut the leading folders and include only the
      subfolder off of the root.
      In addition to the other reply, check out the shared methods of
      'System.IO.Path ' and the 'System.Uri' class.

      --
      M S Herfried K. Wagner
      M V P <URL:http://dotnet.mvps.org/>
      V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

      Comment

      Working...