Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asp.net how to get image url file name

Tags:

asp.net

image

If the user provides the url path to the image, i want to be able to try and download it with with a Webclient. I am using a httpresponse to check the file. Is there a way to grab the file name to make it easier to save? Thanks

like image 591
user516883 Avatar asked Aug 29 '11 20:08

user516883


1 Answers

Try using the Uri Class to load the path and pull the file name from the Segments collection:

Uri uri = new Uri("http://www.domain.com/image.jpg");
string fileName = uri.Segments.Last();
like image 71
jdavies Avatar answered Sep 22 '22 15:09

jdavies