Problem reading from the StandarOutput from ftp.exe. Possible System.Diagnostics.Process Framework b

Posted by SoMoS on Stack Overflow See other posts from Stack Overflow or by SoMoS
Published on 2010-03-18T15:59:55Z Indexed on 2010/03/18 16:01 UTC
Read the original article Hit count: 426

Filed under:
|
|
|

Hello, I was trying some stuff executing console applications when I found this problem handling the I/O of the ftp.exe command that everybody has into the computer. Just try this code:

    m_process = New Diagnostics.Process()
    m_process.StartInfo.FileName = "ftp.exe"
    m_process.StartInfo.CreateNoWindow = True
    m_process.StartInfo.RedirectStandardInput = True
    m_process.StartInfo.RedirectStandardOutput = True
    m_process.StartInfo.UseShellExecute = False
    m_process.Start()
    m_process.StandardInput.AutoFlush = True
    m_process.StandardInput.WriteLine("help")
    MsgBox(m_process.StandardOutput.ReadLine())
    MsgBox(m_process.StandardOutput.ReadLine())
    MsgBox(m_process.StandardOutput.ReadLine())
    MsgBox(m_process.StandardOutput.ReadLine())

This should show you the text that ftp sends you when you do that from the command line:

Los comandos se pueden abreviar. Comandos:

! delete literal prompt send

? debug ls put status

append dir mdelete pwd trace

ascii disconnect mdir quit type

bell get mget quote user

binary glob mkdir recv verbose

bye hash mls remotehelp

cd help mput rename

close lcd open rmdir

Instead of that I'm getting the first line and 3 more with garbage, after that the call to ReadLine block like if there was no data available.

Any hints about that?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about system.diagnostics