【发布时间】:2015-09-07 21:30:13
【问题描述】:
我正在编写一个应用程序,它应该在单击按钮时打开某个进程。但是,用户可以添加新按钮。我将以下代码用于在按钮单击时启动进程的操作:
private void StartProcess(string path)
{
ProcessStartInfo StartInformation = new ProcessStartInfo();
StartInformation.FileName = path;
Process process = Process.Start(StartInformation);
process.EnableRaisingEvents = true;
}
private void ClickFunc(object sender, RoutedEventArgs e)
{
if (File.Exists(ProgramPath))
{
StartProcess(ProgramPath);
}
else
{
MessageBox.Show("Specified path does not exist, please try again.", "Bad File Path Error", MessageBoxButton.OK);
}
}
我想要完成的是,当用户为网页创建一个按钮时,它会打开浏览器,然后是网页。有什么想法吗?
提前谢谢你!
【问题讨论】:
-
不确定我是否完全理解这一点。
ProgramPath在哪里声明和实例化?
标签: c# .net string http arguments