I am curren开发者_开发知识库tly trying to import a list of executables from a text file into a statement:
private void button19_Click(object sender, EventArgs e)
{
Process.Start("test.exe", <Process Name Here>);
}
So If a text file named process.txt contained:
notepad.exe
calc.exe
I would end up with:
Process.Start("test.exe", notepad.exe);
and
Process.Start("test.exe", cacl.exe);
This ought to be what you're after, Michael.
foreach(string exename in System.IO.File.ReadAllLines("yourfile.txt"))
{
Process.Start("test.exe", "\"" + exename + "\"");
}
This will do it:
using (var reader = File.OpenText(pathToFile))
{
string exe = "";
while ((exe = reader.ReadLine()) != null)
{
Process.Start("test.exe", exe);
}
}
精彩评论