<1>
Using system;using system.collections.generic;using system.linq;using system.text;using System.IO;namespace path Path {/ <summary>//path This class is specifically used to manipulate the path. </summary> class Program {static void Main (string[] args) {string str = @ "H:\ Deer Ding Kee \ Eighth. rmvb "; Now we're going to get the name "eighth episode. Rmvb". We can get it that way. string fileName = str. Substring (str. LastIndexOf ("\ \") +1); Console.WriteLine (FileName); Output: Eighth. RMVB//-------------------------------------------------------///In addition to the above method, we have a better way. -------get the file name; string fileName2 = Path.getfilename (str); Console.WriteLine (fileName2); Output: Eighth episode. RMVB//Get file name without extension string fileName3 = Path.getfilenamewithoutextension (str); Console.WriteLine (FileName3); Output: Eighth episode//Get file extension string expansionname = Path.getextension (str); Console.WriteLine (Expansionname); Output:. RMVB//Get a custom path string for absoluteTo path string fullPath = Path.GetFullPath (str); Console.WriteLine (FullPath);//output: H:\ ding lu \ Eighth. RMVB//Connect "two strings" as path string strpath = Path.Combine (@ "D:\ A\ "," b.txt "); Console.WriteLine (strpath); Output: D:\a\b.txt console.readkey (); } }}
The Path class. This class is specifically used to manipulate the path.