过程检查它是一个还是另一个
Process check if it is one or the other
所以我有点卡住了我知道我想要它做什么但不确定该怎么做?
我需要我的 C# 程序来检查哪个是相关的。
private void button1_Click(object sender, EventArgs e)
{
Process.Start("Something.exe");
{
else
{
Process.Start("Somethingelse.exe");
}
}
Close();
}
我将如何做一个简单的检查它是一个还是另一个?
你只需要一个条件语句
bool bStartSomething = false; // Your condition flag
private void button1_Click(object sender, EventArgs e)
{
if (bStartSomething == true)
{
Process.Start("Something.exe");
}
else
{
Process.Start("Somethingelse.exe");
}
this.Close(); // Close GUI
}
如果需要检查进程是否存在,可以试试
// Leave off the .exe when using the process name
var process = Process.GetProcessesByName("Something").FirstOrDefault();
if (process != null)
{
process.Start();
}
所以我有点卡住了我知道我想要它做什么但不确定该怎么做?
我需要我的 C# 程序来检查哪个是相关的。
private void button1_Click(object sender, EventArgs e)
{
Process.Start("Something.exe");
{
else
{
Process.Start("Somethingelse.exe");
}
}
Close();
}
我将如何做一个简单的检查它是一个还是另一个?
你只需要一个条件语句
bool bStartSomething = false; // Your condition flag
private void button1_Click(object sender, EventArgs e)
{
if (bStartSomething == true)
{
Process.Start("Something.exe");
}
else
{
Process.Start("Somethingelse.exe");
}
this.Close(); // Close GUI
}
如果需要检查进程是否存在,可以试试
// Leave off the .exe when using the process name
var process = Process.GetProcessesByName("Something").FirstOrDefault();
if (process != null)
{
process.Start();
}