C# Path class—file path
Given the following string type filePath, it represents a file path:
string filePath = "D:\\Program\\Test\\";
The following are some common methods and execution results in the Path class:
(filePath); //The execution result is ==>"D:\\Program\\Test\\"; (filePath); //The execution result is ==>D:\\Program\\Test (filePath); //The execution result is ==> (filePath); //The execution result is ==>Config (filePath); //The execution result is ==>.txt (filePath); //The execution result is==>D:\
Get the current program directory:
; //Execution result==>"D:\\Program\\Test\\Bin\\Debug\\"; //Execution result==>"D:\\Program\\Test\\Bin\\Debug" ;//Get and set the fully qualified directory of the current directory (the directory from which the process starts)().;//The currently executedexeFile name
C# file path Path class test
Make some time to do a systematic test of the Path class
private void PathTest() { //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- string path = @"C:\Users\cks\Desktop\zzg\ERPWork1125\"; ((path, "txt")); // Output: ------C:\Users\cks\Desktop\zzg\ERPWork1125\ string path1 = @"C:\Users\cks\Desktop\zzg"; string path2 = @"gg/"; ((path1, path2)); //Output: -----C:\Users\cks\Desktop\zzg\gg/ ((path)); //Output: -----C:\Users\cks\Desktop\zzg\ERPWork1125 ((path)); //Output: -----.lua ((path)); //Output: ----- ((path)); //Output: -----User ((path)); // Output: ------C:\Users\cks\Desktop\zzg\ERPWork1125\ (("/x/", ())); //Output: -----"/x/</x//x/|/x/ (("/a/", ())); //Output: ----- " /a/</a//a/|/a/ ((path)); //Output: -----C:\ (()); //Output: ----- (()); //Output: -----C:\Users\cks\AppData\Local\Temp\ ((path).ToString()); //Output: -----True ((path).ToString()); //Output: -----True (()); //Output: -----/ (()); // Output: -----\ (("/x/", )); //Output: -----"/x/</x//x/|/x/ (()); //Output: -----; (()); //Output: -----: // (stdin); //test t = new test(); }
Summarize
The above is personal experience. I hope you can give you a reference and I hope you can support me more.