简体   繁体   English

释放生成C#应用程序后,CommandPrompt命令未运行

[英]CommandPrompt command not run after release the build C# application

I am using a command of a Command Prompt in my application. 我在我的应用程序中使用命令提示符命令。 Application able to run and execute that command of a Command Prompt when I run my application using Visual Studio while debugging but when I take my application's executable file(.exe) and save in my pc drive and then run the file it skips the Command Prompt Command. 当我在调试时使用Visual Studio运行应用程序时,应用程序能够运行并执行命令提示符命令,但是当我将应用程序的可执行文件(.exe)保存在PC驱动器中,然后运行该文件时,它将跳过命令提示符命令。 I research for the topic and get this : CMD command not running in console but no success. 我研究了该主题,并得到以下消息: CMD命令未在控制台中运行,但未成功。

My code : 我的代码:

Process process = new Process();
process.StartInfo.FileName = @"cmd.exe";
process.StartInfo.WorkingDirectory = sentencesList;    
process.StartInfo.Arguments = "/C findstr /V /I \"" + ListOfSomeWords + "\" " + sentencesList+ ">" + filteredList;
process.Start();
process.WaitForExit();
process.Close();
process.Dispose();

Command remove the sentence/line from a text file(sentenceList) which contains a word(ListOfSomeWords) and make a another text file(filteredList) which contains only those line which not contains any of word specify in ListOfSomeWords. 命令从包含单词(ListOfSomeWords)的文本文件(sentenceList)中删除句子/行,并制作另一个文本文件(filteredList),该文本文件仅包含那些不包含ListOfSomeWords中指定的单词的行。

You are not escaping filteredList with quotes. 您没有用引号转义filteredList If it contains a space, then it could not be interpreted correctly by cmd.exe . 如果包含空格,则cmd.exe无法正确解释。

Also make sure that you are setting WorkingDirectory to an existing directory path(variable name file_path looks suspicious). 还要确保将WorkingDirectory设置为现有目录路径(变量名file_path看起来可疑)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM