The ‘Path’ class, in System.IO is very useful and can save you a lot of time and work in getting what you need out of the path. In Classic ASP, using VBScript, with all the mid/left/right functions was a chore. Then, in ASP.Net, these were updated and a little easier, using the substring function. However, that’s not nearly as easy as how you can do it using the ‘Path’ class.
Of course, first, you will need to import the System.IO Namespace, in order to have the Path class available in your pages. Then, given the full path of the file, here are the 5 things you can do with it:
|Get Base Drive Letter||Path.GetPathRoot(PathName)|
|Get Extension Only||Path.GetExtension(PathName)|
|Get Full FileName||Path.GetFileName(PathName)|
All Things DotNet Discussed – Winforms/ASP.Net/SharePoint/WPF