开发者

Process.Start, do nothing if input file == 0 kb

开发者 https://www.devze.com 2023-03-14 01:09 出处:网络
I have a problem, I use Process.Start to launch an executable, although is it possible to say: if input.txt == 0kb do nothing, else e开发者_开发问答xecute process ?

I have a problem, I use Process.Start to launch an executable, although is it possible to say: if input.txt == 0kb do nothing, else e开发者_开发问答xecute process ?

Process.Start("cmd.exe", @"/c test.exe -f input.txt > output.txt").WaitForExit();


Use FileInfo to get the size of the input file and only run the process if it is larger than 0:

FileInfo fi = new FileInfo("input.txt");
if(fi.Length > 0)
{
  Process.Start("cmd.exe", @"/c test.exe -f input.txt > output.txt").WaitForExit();
}
0

精彩评论

暂无评论...
验证码 换一张
取 消