我在e:\ setup.exe中的setup.exe,我试过这段代码:
System.AppDomain.CurrentDomain.BaseDirectory;
返回c:\ Windows \ syswow64 \
Application.ExecutablePath;
返回c:\ Windows \ syswow64 \ MsiExec.exe
Application.StartupPath
返回c:\ Windows \ syswow64 \
我需要回复e:\
答案 0 :(得分:1)
using System.IO;
string exeDir = Directory.GetCurrentDirectory();
你也可以通过反射获得exe完整路径。
string exeLocation = System.Reflection.Assembly.GetEntryAssembly().Location;
你也可以。
string exeDir = AppDomain.CurrentDomain.BaseDirectory;
string exeLocation = Assembly.GetEntryAssembly().Location;
还有一种方法:
string dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
答案 1 :(得分:0)
要获取当前工作目录
System.IO
位于{{1}}
下