Unable to run .exe application using C# code

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.
 
G

Guest

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");
 
K

kbhavesh

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
 
K

kbhavesh

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
 

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

Similar Threads

Process Hanging 2
Process Hanging 6
run application 1
sendkeys give licence error 1
Using COM EXE in C# 3
how to run an application 8
Read Console Context 1
Remote Copy using C# in ASp.net 1

Top