473,320 Members | 1,902 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Passing multiple Arguments to C++ .Exe file through C#

i have exe file generated by the Compilation of C++ program now I want to pass arguments to the generated exe file through C# and save all of the output of exe file on a .txt file this is What i have done so far
public static string RunCmd(params int[] commands)
{
string returnvalue = string.Empty;

ProcessStartInfo info = new ProcessStartInfo("C:\\...\\.exe");
info.UseShellExecute = false;
info.RedirectStandardInput = true;
info.RedirectStandardOutput = true;
info.CreateNoWindow = true;

using (Process process = Process.Start(info))
{
StreamWriter sw = process.StandardInput;
StreamReader sr = process.StandardOutput;

//foreach (int command in commands)
//{
// sw.WriteLine(command);
//}
for (int i = 0; i < commands.Length; i++)
{
sw.WriteLine(commands[i]);
}

sw.Close();
returnvalue = sr.ReadToEnd();
process.Close();
System.IO.StreamWriter file = new System.IO.StreamWriter("C:\\..\\.txt");
file.WriteLine(returnvalue);

file.Close();



return returnvalue;

}
it work well for a single argument but whenever i try to enter multiple Arguments,it just opens the .exe file and not work further
Aug 26 '14 #1
0 1207

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: CroDude | last post by:
Hi all! Please help me with this, I'm stuck here. I have a command line .exe file which needs a few arguments passed to do it's job. In help there's a example like this: ...
2
by: Paul Hale | last post by:
Hi all, being new to c# I'm trying to find the best way of passing multiple records to insert into a sql database via a stored procedure. I'm using visual studio 2005 RC SQL server 2005 and C# of...
1
by: Roy | last post by:
I'm assuming this is amazingly simple and I'm just missing the boat. On the html side of an asp.net page I have a datagrid, a "search" button, and 8 text boxes for search criteria. A user enters...
8
by: Ritesh Raj Sarraf | last post by:
Hi, I'm having some minor problems with optparse. I'm just worried that someone shouldn't say that multiple argument feature isn't implemented in optpartse. How to tackle multiple arguments...
1
by: chariclark | last post by:
This may be a quick fix post... ---------------------------- I am having trouble passing multiple values into stored procedure. Here it is below: CREATE Procedure spGetAssociateds ( @PDSI...
4
by: lab3terch | last post by:
I have written the following code: Public Class Form1 Private Sub CmdCount_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdCount.Click Dim instotal,...
4
by: Nathan Sokalski | last post by:
I am a beginner with AJAX, and have managed to learn how to use it when passing single parameters, but I want to return more than one value to the client-side JavaScript function that displays it....
1
by: ashokbio | last post by:
How to return multiple values by passing multiple arguments in function or subroutine using VB6? T. Ashok Kumar
1
cypherzero
by: cypherzero | last post by:
Some C functions like printf take an unlimited number of arguments of various types. Does anyone know how such a function is created, stdio.h doesn't give much of a clue, specifying only '...' and...
0
by: yshali | last post by:
Hi, I am trying to write sql for passing multiple arguments through a function and handle NULL conditions ? here is the part of the query which throws error: ... and a.itemnum in...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.