[Mono-list] Process and RedirectStandardError issues....

J.M.Villagrá mono at villagra.info
Wed May 18 05:42:59 EDT 2005


 Hi, i'm developing a lftp gui, but im having problems when i redirect the
ErrorOutput...  i only can read one line, then the streamreader.peak()
goes -1, but there are more lines to read!!... if i dont use a while and
put a lot of stramreader.readline() i can read it, but i dont have
control about the number of lines...  ???

The full source code is here:

www.villagra.info/mono/ftpclient.tar.gz

The problematic code is:

  if (ftp_job.sErr.Peek() >= 0 ) {
   while (ftp_job.sErr.Peek() >= 0 ) {
    output = ftp_job.sErr.ReadLine ();
    Console.WriteLine (ftp_job.sErr.Peek());
    app.AddLogMessage (output); // put the message on a StoreList
   }
  }


And the lftp class:

public class LFtp {

 Process myProcess;

 public StreamWriter sIn;
    public StreamReader sOut;
    public StreamReader sErr;

 public LFtp (){

  myProcess = new Process();

  myProcess.StartInfo.UseShellExecute = false;
     myProcess.StartInfo.RedirectStandardInput = true;
     myProcess.StartInfo.RedirectStandardOutput = true;
     myProcess.StartInfo.RedirectStandardError = true;
  myProcess.StartInfo.FileName = "lftp";

 }

 public void open (string server, string port, string user, string
password) {

  myProcess.StartInfo.Arguments = server + " -u " + user + "," + password;
   myProcess.Start();

  //Streamreaders
  sIn  = myProcess.StandardInput;
     sOut  = myProcess.StandardOutput;
     sErr  = myProcess.StandardError;

     sIn.AutoFlush = true;
  //sOut.DiscardBufferedData ();

     sIn.WriteLine ("cache off");
     sIn.WriteLine ("debug 6");
     sIn.WriteLine ("cd leer");
     sIn.WriteLine ("ls -la");
 }


More information about the Mono-list mailing list