C# Remove URL from String -


this seems easy 1 try doesn't seem work

say have following string:

string mystring = "http://www.mysite.com/folder/file.jpg"; 

how can process remove url , leave "file.jpg" string value?

thanks!

kris

you can use system.io.path methods

string mystring = "http://www.mysite.com/folder/file.jpg"; string filename = path.getfilename(mystring); // file.jpg 

if want process more complex uris can pass thought system.uri type , grab absolutepath

string mystring = "http://www.mysite.com/folder/file.jpg?test=1"; uri uri = new uri(mystring); string file = path.getfilename(uri.absolutepath); 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -