Do I use a regular expression on this file path?

Posted by uno on Stack Overflow See other posts from Stack Overflow or by uno
Published on 2010-04-20T19:09:32Z Indexed on 2010/04/22 8:13 UTC
Read the original article Hit count: 241

Filed under:

I have to strip a file path and get the parent folder.

Say my path is

\\ServerA\FolderA\FolderB\File.jpg

I need to get

  1. File Name = File.jog

  2. Folder it resides in = FolderB

  3. And parent folder = FolderA

I always have to go 2 levels up from where the file resides.

Is there an easier way or is a regular expression the way to go?

© Stack Overflow or respective owner

Related posts about c#