Splitting A File's Path

I am loading a bunch of file paths from one file. Here is an example. Original string is "Projects\\Shine\\bin\\debug". What I want is "Projects", "Shine", "bin", and "debug" all in separate strings.


Answer this question

Splitting A File's Path

  • Ted12893

    Hi,

    you can use the sting.Split command using the \ character as the deliminator. That method will return an array of string for you.

    Mark.



  • Vijay Chegu

    Hi Wasting <g>,

    If you feel the issue is resolved to your liking...mark the post(s) that helped you as the answer(s), so when others search the forums, they might be more inclined to look at a successful post than a non successful one and determine which post(s) are the most helpful. Also in the search results the Answered posts are bubbled to the top before the unanswered.

    Or post if you need more help! Thanks



  • wgpubs

    Mark Dawson wrote:

    Hi,

    you can use the sting.Split command using the \ character as the deliminator. That method will return an array of string for you.

    Mark.



    Very true but it will return the drive letter within the first match. So that can be used if one ignores the first item.


  • DevDiver

    You want to use Path object found in System.IO which has some useful statics such as GetFileName GetFullPath and GetExtension to name a few.

  • Senthil.P

    Thank you so much OmegaMan.

  • Splitting A File's Path