Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Everyone! Need to get some help here~

This is my coding. Below

C#
string[] readTexts = File.ReadAllLines("/Users/Code/Desktop/Testing.bat");
            foreach (string s in readTexts)
            {

                if(s == "-C")
                {
                    MessageBox.Show("helo");
                }

            }


My bat files text is
@ECHO off
ECHO Executing Run Exe!
@ECHO on

"C:\Users\Code\Documents\Run.exe"  -C


Question is how can i read the "-C" on the 5th rows on the bat files? My Coding is not working because they read the whole lines. Wish to get some solution or help from you guys! Thanks
Posted
Updated 21-Nov-13 14:27pm
v3
Comments
Sergey Alexandrovich Kryukov 21-Nov-13 20:46pm    
You will read them, not what? Instead of using batch file, why not just performing its task, as soon as you already using C#..?
—SA

hi.

C#
var readTexts = File.ReadAllLines("/Users/Code/Desktop/Testing.bat");
foreach (var s in readTexts)
{
	if(s.EndsWith("-C"))
	MessageBox.Show("hello! The line with \"-C\" is: " + s);
}
 
Share this answer
 
Thank You so much! Its Working now!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900