myVar = "D:\\mainfolder\\subf1\\subf2\\subf3\\file.txt";
How can I get file.txtcomfortable in .NET 2.0 with C #? What I know is split using \\and trying to get the last element.
file.txt
\\
Thank.
string fileNameOnly = Path.GetFileName("D:\\mainfolder\\subf1\\subf2\\subf3\\file.txt");
must return file.txt
Binding Path Class Documentation on MSDN. It has many other convenient methods.
System.IO.Path.GetFileName(myVar);