Click here to Skip to main content
15,916,462 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
at run time we can have any path from below,
HTML
path=d:\abxyz.xml
path=d:\abcmn\a\xyiopoipoz.xml
path=d:\abc\a\bsa\xysaz.xml

I want to get only the name of XML file.. mean that i want to ignore the string till last \....
rite now i am hardcoding by path.substring(#).


Thanks in advance
Posted
Updated 4-Jul-12 21:01pm
v3
Comments
Ali_100 5-Jul-12 5:15am    
I have solved it by

http://msdn.microsoft.com/en-us/library/system.io.path.getfilename(v=vs.90).aspx

1 solution

use substring propery with lastndexof

C#
String a = "YOUR PATH";
String b = "";
if(a.Contains(@"\\"))
{
b = a.Substring(a.LastIndexOf(@"\")+1);
}



Regards
Sebastian
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900