开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜