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(@"\"));
4.
string filePath = AppDomain.CurrentDomain.BaseDirectory + @"\..\测试\1.xml";
实际路径是(AppDomain.CurrentDomain.BaseDirectory的上一层)\测试\1.xml
退几层就是几个..\
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)