//获取当前运行程序的目录
Application.StartupPath;
Environment.CurrentDirectory;
//一个文件目录
string filePath = "C:\\JiYF\\BenXH\\BenXHCMS.xml";
System.IO.Path.GetFullPath(filePath); //-->C:\JiYF\BenXH\BenXHCMS.xml
System.IO.Path.GetDirectoryName(filePath); //-->C:\JiYF\BenXH
System.IO.Path.GetFileName(filePath); //-->BenXHCMS.xml
System.IO.Path.GetFileNameWithoutExtension(filePath); //-->BenXHCMS
System.IO.Path.GetExtension(filePath); //-->.xml
System.IO.Path.GetPathRoot(filePath); //-->C:\
本文介绍了使用C#进行文件路径操作的方法,包括获取文件全路径、目录名、文件名及扩展名等实用技巧。
2571

被折叠的 条评论
为什么被折叠?



