C#杂项

取文件短名称:

shortname= Path.GetFileNameWithoutExtension(filename);      无扩展名
shortname = filename.Substring(filename.LastIndexOf('\') + 1);  有扩展名

取执行文件路径:

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


组合文件路径
filePath = System.IO.Path.Combine(appPath, filePath);

原文地址:https://www.cnblogs.com/wfy680/p/12047350.html