473,769 Members | 2,140 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help with System.Diagnost ics.Process.Sta ndardOutput buffer size.

1 New Member
Hi, I'm using VS 2005, ,.net 2 for C# windows application. I'm using Process
to run a C application and redirecting its standard output so I can read it
with StreamReader.Re adToEnd. It's only reading the 1st 5 lines or so when
there is about 100 lines of data.
I also tried using the Process.BeginOu tputReadlin and a
DataReceivedEvn tHandler to gather output but I also only get about 5 lines of
the data.
There seems to be a buffer size issue. Can someone tell me how can I
resolve this problem. Thank you.


static System.Text.Str ingBuilder sb = new System.Text.Str ingBuilder();
static void proc_OutputData Received(object sender, DataReceivedEve ntArgs e)
{
sb.Append(e.Dat a);
}

public static int GetNisFile(Syst em.Diagnostics. ProcessStartInf o psi, string parm,
ref DataTable dtAccounts,
ref ToolStripStatus Label slMain, ref StatusStrip ssMain, string userOrGroup)
{

string accountFile = "", output = "", line = "", theResult="";
int numOfAccounts = 0;
String inputText;
int numInputLines = 0;
System.IO.Strea mReader fileOutput = null, myOutput = null;
System.Diagnost ics.Process listFiles = new Process();
//listFiles.Start Info = psi;
try
{
listFiles.Outpu tDataReceived += new DataReceivedEve ntHandler(proc_ OutputDataRecei ved);
listFiles.Start Info = new ProcessStartInf o(Application.S tartupPath +
"\\ypcat.ex e", parm);
listFiles.Start Info.UseShellEx ecute = false;
listFiles.Start Info.RedirectSt andardOutput = true;
listFiles.Start Info.RedirectSt andardError = true;
//listFiles = System.Diagnost ics.Process.Sta rt(psi);
// Use a stream writer to synchronously write the sort input.
if (listFiles.Star t())
{
//StreamReader nisReader = listFiles.Stand ardOutput;
listFiles.Begin OutputReadLine( );
string error = listFiles.Stand ardError.ReadTo End();
listFiles.WaitF orExit();
if(listFiles.Ha sExited)
theResult = sb.ToString();
listFiles.Cance lOutputRead();
listFiles.Close ();
}
return numOfAccounts;



}
catch (Win32Exception wex)
{
MessageBox.Show (wex.Message, "PowerADvantage ");
return numOfAccounts;
}
}
Aug 6 '07 #1
1 3088
kenobewan
4,871 Recognized Expert Specialist
Here is an example that may help:
POSTing Data with ASP.NET
Aug 6 '07 #2

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

Similar topics

9
5043
by: Tommy Lu | last post by:
Hi, wondering if there is a way to interact the shell command with the C# program? For example, if I type c:\>ver it then suppose to return the version of the OS I am currently using... or c:\>systeminfo
7
2970
by: ~toki | last post by:
I have a full work app (server and client) that talk between two executables trought Console.WriteLine(); & Console.ReadLine(); I have the source code of the server. I need to make the client. To do this i have Console.WriteLine("Hi server"); while (true)
4
1928
by: Tressa | last post by:
I have a messagebox that I only want to pop up only if it is not already being displayed on the screen. My code is still poping up the messagebox even though it is on the screen. What am I doing wrong here. Any suggestions on how to fix this using System; using System.Collections; using System.ComponentModel;
1
5989
by: solex | last post by:
Hello All, Hopefully someone has run into this error. I have written a class(source below) that launches a thread to monitor the StandardOutput of a System.Diagnostics.Process, in particular I am executing the find.exe program. The application works perfectly in the development environment. As soon as I execute the compiled program and start the find process I get an "Application Error". The error states that the instruction...
22
9258
by: SQACSharp | last post by:
I'm trying to get the control name of an editbox in another window. The following code set the value "MyPassword" in the password EditBox but it fail to return the control name of the EditBox. I'm sure the problem is the way i'm using the sendmessage API, the return string and the lParam return 0....is anybody have a clue? any sendmessage api expert here? public static extern Int32 FindWindow(String lpClassName,String
0
2245
by: smimon | last post by:
Hi I'm trying to run a DTS package from a ASP.NET web page using System.Diagnostics.Process. This DTS takes up to 10 minutes to complete, during which, output is generated which i would like to trap and output to a client. Having read a bit of literature about this, i realise that it is necessary to start a new thread to report on the progress of the process using StandardOutput. However, the first attempt to read from this stream causes...
11
11964
by: Jon Davis | last post by:
Does anyone know why using System.Diagnostics.Process to "wrap" a console application does not always transmit the I/O, depending on what processes you're trying to "consume"? PowerShell, for example, does not seem to process any I/O through the Process object. I know that in the case of PowerShell there are better ways to "wrap" the console by directly interfacing with the assemblies of System.Management.Automation or some similarly...
1
2665
by: Tony Freixas | last post by:
Hello, I'm trying to create a wrapper for a program. I want to execute program 'X' by running program 'Y', such that 'Y' appears to function pretty much like 'X' both in the way command line options are handled and the way input, output and error messages are reported. Program 'X' is a console application. I had it pretty well figured out, I thought, until I ran into a case where program X spit out ZIP code. In other words, I was...
0
3020
by: =?Utf-8?B?UHVjY2E=?= | last post by:
-- Hi I'm using vs2005, .net 2 for windows application. The application I started using System.Diagnostics.Process is having a "listFiles.StandardOutput" buffer size problem. I was wondering where and how can I adjust the buffer size problem. I don't want to be limited to a set buffer size, is that possible? thank you. public static int GetNisFile(System.Diagnostics.ProcessStartInfo psi, ref DataTable dtAccounts, ref...
0
10208
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10038
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9987
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9857
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8867
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5294
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3558
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2812
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.