想通过main()函数传递参数,先重载下面的OnStartup()

 

 public partial class App : Application
    {
        public static string args0;
        protected override void OnStartup(StartupEventArgs e)
        {            
            if(e.Args != null && e.Args.Length > 0)
                args0 = e.Args[0].ToString();
            base.OnStartup(e);
        }
    }

 

然后在App.xaml中看到StartupUri="MainWindow.xaml"

那么在MainWindow.xaml.cs中就可以通过App.args0获取传递进来的参数了

 

 

若想调用外部程序用 Process.Start("绝对路径+xx.exe", "参数1"); 

相关文章:

  • 2021-05-17
  • 2021-07-28
  • 2022-01-01
  • 2021-07-24
  • 2021-08-10
  • 2022-01-30
  • 2021-10-06
  • 2022-12-23
猜你喜欢
  • 2021-10-28
  • 2021-12-19
相关资源
相似解决方案