C# – How to extract file name from an Uri in C#?

curi

Possible Duplicate:
Get file name from URI string in C#

How to extract file name from an Uri in C#?

for instance, I have a Uri

"http://audacity.googlecode.com/files/audacity-win-2.0.exe"

but how to extract the file name

"audacity-win-2.0.exe"

and save it as a string?

Thank you,

Jerry

Best Answer

How about

Path.GetFileName(string path);

In your case

Path.GetFileName(new Uri("http://audacity.googlecode.com/files/audacity-win-2.0.exe").AbsolutePath);