SolutionCottage.com
Posted  13 Mar 2009 - 13:35:52

Category: ASP.net


Get the file name from path in .NET

Issue:
You have a folder, something like "C:\blah\bleh/unixslash/file.txt" and you want the file name, in this case "file.txt".

Solution:
There is a built in function in System.IO called Path.GetFileName(string);

Use it something like this:

string rawPath = "C:\blah\bleh/unixslash/file.txt";
string fileName = Path.GetFileName(rawPath);








0 comments:








© SolutionCottage 2008-2011 9/26/2017 10:07:32 AM