Unable to run .exe application using C# code

  • Thread starter Thread starter kbhavesh
  • Start date Start date
K

kbhavesh

Hi,

I have an exe that i need to call from my C# Program with two
arguments(filenames)

for example
Suppose if i have an application "test.exe" , whose functionality is to
convert a '.doc' file to '.txt' file
On cmd i would normally give the following command as:

test.exe abc.doc xyz.txt

and it works fine and performs its job of conversion.

but what if i want to execute the same thing using my c# code.
i am using the following sample code:

Process compiler = new Process();
compiler.StartInfo.FileName = "test.exe" ;
compiler.StartInfo.Arguments = "abc.doc xyz.txt" ;
compiler.StartInfo.UseShellExecute = false;
compiler.StartInfo.RedirectStandardOutput = true;
compiler.Start();

when i try to invoke the test.exe using the above code , it fails to
perform its operation of conversion.

how is setworking directory to be used?
how should we specify the path for all the files.?
how should we give the path for the above files to be used?

Can anyone tell me if i need to add anything more to the above code

It would be great if somebody could provide some help on the above
topic.
 
Did you put test.exe and you program together?
If not, you should give the full name of test.exe .
Such as:
Process.Start("c:\\test.exe","abc.doc xyz.txt");
 
Thanks for the suggestion !
Actually i have tried this , but still does'nt seem to work
if u have some other suggestion , plz do post again.

bhavesh
 
Is it required to have all the files in the same directory?
For example:
Process.Start("C:\\My Folder\\test.exe", "D:\\abc.doc C:\\test
folder\\xyz.txt");

Will it work?

Thanks,
BK
 
Back
Top