-3

I am given a path like this:

string pathFolder = "D:\\New folder\anotherFolder\folder\something.txt\";

and I have to extract every detail of this path using only string methods. Without any other library help.

Can anyone help me, please?

5
  • 5
    not clear on what you mean by "Without any Csharp help."
    – HatSoft
    Aug 6, 2012 at 10:42
  • First thing that comes into mind would be string.Split but its C# as such ! !, so maybe javascript split ?
    – V4Vendetta
    Aug 6, 2012 at 10:46
  • 5
    Presumably you mean without using the .net framework's Path class in System.IO, which suggests to me this is some sort of lame homework exercise. Aug 6, 2012 at 10:48
  • I apologize for I wasn't clear enough. By "Without any Csharp help" I ment ... without any other formats than string.format.
    – Angelo
    Aug 6, 2012 at 11:05
  • string.Format can't extract anything from a string. It can only be used to build up new strings. Please clarify what you can use. Do you mean that you can only use the methods defined on the string class?
    – Oded
    Aug 6, 2012 at 12:21

1 Answer 1

0

Just use string.Split:

var parts = pathFolder.Split(new [] {'\\'}, StringSplitOptions.RemoveEmptyEntries);

The better option is to use the Path class.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.