C# 如何获取可执行文件路径的上上级目录


1、

DirectoryInfo di = new DirectoryInfo(string.Format(@"{0}..\..\", Application.StartupPath));

di.FullName

就是你想要的

..\有几个就是往回退几层

2、

DirectoryInfo info = new DirectoryInfo(Application.StartupPath);

String path = info.Parent.Parent.FullName;

 

3、

 

string WantedPath = Application.StartupPath.Substring(0,Application.StartupPath.LastIndexOf(@"\"));

 

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM