C # Gets the file name and extension

string fullPath = @"d:\test\default.avi";

 

string filename = Path.GetFileName (fullPath); // Returns the file name with the extension "default.avi"
String Extension = Path.GetExtension (fullPath); // extensions "the .aspx"
String fileNameWithoutExtension = Path.GetFileNameWithoutExtension (fullPath ); // no extension of the file name "default"


String dirpath = Path.GetDirectoryName (filePath) // returns the directory where the file "d: \ the Test"
String fullPath1 = Path.Combine (@ "d: \ the Test", " default.avi ") // returns" D: \ Test \ default.avi "

string fullPath2 = Path.GetFullPath (" the config.ini "); // returns the absolute pathname specified path string

Guess you like

Origin www.cnblogs.com/ctwanyou/p/11720231.html