Skip to content

Instantly share code, notes, and snippets.

@h4r7w3l1
Last active January 20, 2021 23:41
Show Gist options
  • Save h4r7w3l1/8f5ded5eae4e643c59d2dbbcf91ab468 to your computer and use it in GitHub Desktop.
Save h4r7w3l1/8f5ded5eae4e643c59d2dbbcf91ab468 to your computer and use it in GitHub Desktop.
string hreflink = "http://dpomain.com/path/somefile.txt";
//string hreflink = "http://cdn.p30download.com/.Mozilla.Firefox.v58.0.x86_p30download.com.zip";
Console.WriteLine("link: "+ hreflink);
Uri uri = new Uri(hreflink);
Console.WriteLine("uri: "+ uri);
string filename = System.IO.Path.GetFileName(uri.LocalPath);
Console.WriteLine("GetFileName: "+ filename);
Console.WriteLine("GetFullPath: "+ System.IO.Path.GetFullPath(uri.LocalPath));
Console.WriteLine("============= ");
var uri2 = new Uri(hreflink);
var filename2 = uri.Segments.Last();
Console.WriteLine("path2: "+ filename2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment