2024年1月22日发(作者:)
// Do not redirect the error output. ctStandardError = false; } ine("nStarting process: net {0}",
nts); if (errorRedirect) { ine("Errors will be written to the file {0}",
netErrorFile); } // Start the process. (); // Start the asynchronous read of the standard output stream. utputReadLine(); if (errorRedirect) { // Start the asynchronous read of the standard // error stream. rrorReadLine(); } // Let the net command run, collecting the output. rExit(); if (streamError != null) { // Close the error file. (); } else
{ // Set errorsWritten to false if the stream is not // open. Either there are no errors, or the error // file could not be opened. errorsWritten = false; } if ( > 0) { // If the process wrote more than just // white space, write the output to the console. ine("nPublic network shares from net view:n{0}n",
netOutput); } if (errorsWritten) { // Signal that the error file had something
// written to it. String [] errorOutput = lLines(netErrorFile); if ( > 0) { ine("nThe following error output was appended to {0}.", netErrorFile); foreach (String errLine in errorOutput) { ine(" {0}", errLine); } } ine(); } (); } private static void NetOutputDataHandler(object sendingProcess,
DataReceivedEventArgs outLine) { // Collect the net view command output. if (!OrEmpty()) { // Add the text to the collected output. (e + " " + ); } } private static void NetErrorDataHandler(object sendingProcess,
DataReceivedEventArgs errLine) { // Write the error text to the file if there is something // to write and an error file has been specified. if (!OrEmpty()) { if (!errorsWritten) { if (streamError == null) { // Open the file. try
{ streamError = new StreamWriter(netErrorFile, true);


发布评论