In my console application, I need to execute a series of commands:
D:
cd d:\datafeeds
grp -encrypt -myfile.xls
This set of commands actually encrypt a file using a tool (gpg).
How will I do it ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Create a batch file that contains your commands.
Then use Process.Start and ProcessStartInfo class to execute your batch.
ProcessStartInfo contains other useful properties See MSDN docs
Process and ProcessStartInfo require an
using System.Diagnostics;In this scenario (when you need to run command line tools) I prefer to use the batch approach instead of coding everything through the ProcessStartInfo properties. It will be more flexible when you have to change something and you have not the code available.