[ACCEPTED]-how to parse out image name from image url-url

Accepted answer
Score: 29
string fileName = Path.GetFileName(@"http://www.google.com/test/test23/image1.jpg");

0

Score: 5

As long as your sure its an image file you 1 can just use the path class.

System.io.path.GetFilenAME

Score: 1
public static void doSomething() {
    string url = "http:\\www.google.com\image1.jpg";
    string imageFileName = url.Substring( url.LastIndexOf( '\\' ) + 1 );
}

0

Score: 1

Not the best, but a certainly a way

url = "blahblah\image1.jpg"

string imageName  = url.substring(url.lastindexof("\") + 1); 

0

More Related questions