troubleshooting Question

Need help with System.Diagnostics.Process.StandardOutput buffer size.

Avatar of lapucca
lapucca asked on
C#
12 Comments1 Solution2338 ViewsLast Modified:
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 ToolStripStatusLabel slMain, ref StatusStrip ssMain, string userOrGroup)
{

    string accountFile="", output="";
    int numOfAccounts = 0;
    System.IO.StreamReader fileOutput = null, myOutput = null;
    System.Diagnostics.Process listFiles;
    try
    {
        listFiles = System.Diagnostics.Process.Start(psi);
        if (listFiles != null)
        {
            myOutput = listFiles.StandardError;
            fileOutput = listFiles.StandardOutput;
            listFiles.WaitForExit(30000);
            if (listFiles.HasExited)
            {
            // Read and display lines from the file until the end of
            // the file is reached.
                accountFile = fileOutput.ReadToEnd();
                output = myOutput.ReadToEnd();
                if (accountFile != null && accountFile != "")
                    numOfAccounts = CPAUnix.ParseAndInsertAccounts(accountFile,
                        ref dtAccounts, ref slMain, ref ssMain, userOrGroup);
            }
            else
                MessageBox.Show("Time out retrieving NIS" + userOrGroup + "accounts.",
                    "PowerADvantage");
        }
        else
            MessageBox.Show("Error starting process to read file.", "PowerADvantage");

        return numOfAccounts;

    }
    catch (Win32Exception wex)
    {
        MessageBox.Show(wex.Message, "PowerADvantage");
        return numOfAccounts;
    }
}
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 12 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 12 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros