Running command line commands with parameters read from a text fil

O

orit

I am trying unsuccessfully to implement the following:
Run a command in command line (cmd.exe) while the command will use parameter
read from a text file.
The user will select the file to read in a winform and the same command will
run in a loop while using in each run the value in 1 single line in the text
file.

Can someone please advise what is the best way to do that?

Thanks a lot
 
H

Hayato Iriumi

Are you trying to have your window form application use a text file
when it starts? Couldn't you pass the path to the text file and
receive it in static Main(string[] args) ?
 
T

Thiago Macedo

Are you trying to have your window form application use a text file
when it starts? Couldn't you pass the path to the text file and
receive it in static Main(string[] args) ?

I am trying unsuccessfully to implement the following:
Run a command in command line (cmd.exe) while the command will use parameter
read from a text file.
The user will select the file to read in a winform and the same command will
run in a loop while using in each run the value in 1 single line in the text
file.
Can someone please advise what is the best way to do that?
Thanks a lot

Using StreamReader to read line per line, you can run a command with
Process class (http://msdn.microsoft.com/en-us/library/
system.diagnostics.process.aspx). Loop through txt lines concatening
the parameter to your command and run the process, till it ends
(WaitForExit).

Hope it help

Thiago
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top