Could you help me for finding the file name from the string. Now i have one string of content like \"C:\\xxxx\\xxxx\\xxxx\\abc.pdf\". But i want only the file name ie. abc.p
Use the Path.GetFileName() Method
(Edited) sample from the MSDN-page:
string fileName = @"C:\xxxx\xxxx\xxxx\abc.pdf";
string path = @"C:\xxxx\xxxx\xxxx\";
string path2 = @"C:\xxxx\xxxx\xxxx";
string result;
result = Path.GetFileName(fileName);
Console.WriteLine("GetFileName('{0}') returns '{1}'",
fileName, result);
result = Path.GetFileName(path);
Console.WriteLine("GetFileName('{0}') returns '{1}'",
path, result);
result = Path.GetFileName(path2);
Console.WriteLine("GetFileName('{0}') returns '{1}'",
path2, result);
This code produces output similar to the following:
GetFileName('C:\xxxx\xxxx\xxxx\abc.pdf') returns 'abc.pdf'
GetFileName('C:\xxxx\xxxx\xxxx\') returns ''
GetFileName('C:\xxxx\xxxx\xxxx') returns 'xxxx'