简体   繁体   中英

Start a wpf.exe application with a c# console app?

I have a wpf application (.exe) on my desktop. I made ac# console application that have to start it. But I get a FileNotFoundException

This is what I have:

 var process = new Process();
 process.StartInfo.FileName = "MyWpfAPp.exe";
 process.Start();

Did I forget something?

This will do the trick for you if the file is on and always will be on your desktop

var fileLocation = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
var fileName = "MyWpfAPp.exe";

var path = Path.Combine(fileLocation, fileName );

var process = new Process();
process.StartInfo.FileName = path;
process.Start();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM