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. I research for the topic and get this : CMD command not running in console but no success.
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.
You are not escaping filteredList
with quotes. If it contains a space, then it could not be interpreted correctly by cmd.exe .
Also make sure that you are setting WorkingDirectory to an existing directory path(variable name file_path looks suspicious).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.