C#在工具重新启动后使用启动参数
在应用程序重新启动后,如何使用启动参数 我以以下方式传递参数:C#在工具重新启动后使用启动参数,c#,arguments,launch,C#,Arguments,Launch,在应用程序重新启动后,如何使用启动参数 我以以下方式传递参数: private void updateApplication(string tempFilePath, string currentPath, string newPath, string launchArgs) { string argument = "/C Choice /C Y /N /D Y /T 4 & Del /F /Q \"{0}\" & Choice /C Y /N /D Y /T 2
private void updateApplication(string tempFilePath, string currentPath, string newPath, string launchArgs)
{
string argument = "/C Choice /C Y /N /D Y /T 4 & Del /F /Q \"{0}\" & Choice /C Y /N /D Y /T 2 & Move /Y \"{1}\" \"{2}\" & Start \"\" /D \"{3}\" \"{4}\" {5}";
ProcessStartInfo info = new ProcessStartInfo();
info.Arguments = string.Format(argument, currentPath, tempFilePath, newPath, Path.GetDirectoryName(newPath), Path.GetFileName(newPath), launchArgs);
info.WindowStyle = ProcessWindowStyle.Hidden;
info.CreateNoWindow = true;
info.FileName = "cmd.exe";
Process.Start(info);
}
现在该工具将升级并重新启动,但如何在新的重新启动时使用launchArgs中存储的传递参数?传递的参数可以在entry方法中访问
class Program
{
static void Main(string[] args)
{
// args contains the arguments passed at startup.
}
}
传递的参数可以在entry方法中访问
class Program
{
static void Main(string[] args)
{
// args contains the arguments passed at startup.
}
}
看起来你已经在这么做了。如果你想让这些坚持下去,我会考虑把它们放在你的例子中,当你得到更新命令时,把它们从那里拉过来,沿着 传递,看起来你已经在做了。如果你想让这些坚持下去,我会考虑把它们放在你的例子中,当你得到更新命令时,把它们从那里拉过来,沿着传递给新的启动toopas参数,直到新的启动tooyea,我一直在尝试,现在我很遗憾地收到了以下错误:没有给出与“startUp.startUp(string[])”的必需形式参数“args”相对应的参数,因为它无法在正常启动时传递参数,仅在更新之后。但我无法访问传递的值。因此我实际上想检查是否有传递的值并显示messagebox。是的,我一直在尝试,现在我很遗憾地收到以下错误:没有给出与startUp.startUp(string[]的必需形式参数'args'相对应的参数'因为只有在更新之后,它才能在正常启动时获得传递的参数。但我无法访问传递的值。因此我实际上想检查是否有传递的值并显示messagebox。