C # Miscellaneous

Take the short file name:

shortname = Path.GetFileNameWithoutExtension (filename); no extension
shortname = filename.Substring (filename.LastIndexOf ( '\\ ') + 1); have the extension

 

Take execute the file path:

string appPath = System.IO.Path.GetDirectoryName(Application.ExecutablePath);
string filePath = "image\Star.jpg";


Combined file path
filePath = System.IO.Path.Combine (appPath, filePath) ;

Guess you like

Origin www.cnblogs.com/wfy680/p/12047350.html