【发布时间】:2020-05-09 11:38:22
【问题描述】:
当我尝试使用快捷方式或 Process.Start 启动我的程序时,它正在运行我的 if,说我的文件丢失并且它没有启动 WPF 窗口。下图是我试图通过快捷方式启动的/process.start
if (!File.Exists(Environment.CurrentDirectory + "\\Multimanager.dll") && !File.Exists(Environment.CurrentDirectory + "\\Multimanager.dll"))
{
MessageBox.Show("You are missing the 'Multimanager.dll' and the 'Updater.dll'. Please re-run the MMInstaller.exe to re-download these files", "Missing files", MessageBoxButton.OK, MessageBoxImage.Warning);
Application.Current.Shutdown();
}
else if (!File.Exists(Environment.CurrentDirectory + "\\Multimanager.dll"))
{
MessageBox.Show("You are missing the 'Multimanager.dll'. Please re-run the MMInstaller.exe to re-download these files", "Missing files", MessageBoxButton.OK, MessageBoxImage.Warning);
Application.Current.Shutdown();
}
else if (!File.Exists(Environment.CurrentDirectory + "\\Updater.dll"))
{
MessageBox.Show("You are missing the 'Updater.dll'. Please re-run the MMInstaller.exe to re-download these files", "Missing files", MessageBoxButton.OK, MessageBoxImage.Warning);
Application.Current.Shutdown();
}
else
{
string MMV = Multimanager.MMShared.version().ToString();
string UV = Updater.UShared.version().ToString();
var u = new Updater.UpdaterWPF(MMV);
u.ShowDialog();
var mm = new Multimanager.UUpdater(UV);
mm.Show();
u.Close();
}
编辑:如果我使用 .exe 手动启动程序,它会正常打开(哦,如果它是 64 位应用程序,IDK 与它有任何关系)
编辑:这是我的 process.start Process.Start(path.Text + "\\Multimanager Launcher.exe"); 并且 path.text 是屏幕截图中的目录。
快捷方式是使用本网站上的代码here
【问题讨论】:
-
请不要将代码发布为图片
-
看不到您的 process.start 代码会很困难,但是您是否将工作目录设置为程序所在的目录?顺便说一句:请发布您的代码,而不是屏幕截图。
-
我马上贴出来
-
1.您的第一个
IF检查相同的条件 2.尝试使用appDomain.CurrentDomain.BaseDirectory而不是Environment.CurrentDirectory3.将您的代码发布为格式化文本而不是图片
标签: c# if-statement shortcut system.diagnostics process.start