Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 704277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:55:27+00:00 2026-05-14T03:55:27+00:00

I execute the ftp.exe cmd through a C# System.Diagnostics.Process type. And I use the

  • 0

I execute the http://ftp.exe cmd through a C# System.Diagnostics.Process type. And I use the following code to get the “ftp.exe” output after I programmatically enter a “help” command. But I can only get the first line of the result. And I never get to the “end” output part. The whole program seems blocked.

    Process p = new Process();
    p.StartInfo.FileName = @"C:\Windows\System32\ftp.exe";
    p.StartInfo.CreateNoWindow = true;
    p.StartInfo.RedirectStandardInput = true;
    p.StartInfo.RedirectStandardOutput = true;
    p.StartInfo.RedirectStandardError = true;

    p.StartInfo.UseShellExecute = false;
    p.Start();

    p.StandardInput.WriteLine("help");

    Int32 c_int = p.StandardOutput.Read();
    while (c_int != -1)
    {
        Char c = (Char)c_int;
        Console.Write(c);
        c_int = p.StandardOutput.Read();
    }

    Console.WriteLine("end");

However, I write a simple program which only use Console.Writeline() to write some output to its StdOut stream. And I test it with the above code. It works fine. I just cannot figure out why the above code cannot work with http://ftp.exe? The only difference between my SimpleConsoleOutput program and the “ftp.exe” is that the http://ftp.exe has its own interactive command prompt.

(————— New Progress —————–)

Here’re some progress of my personal investigation.

I write 2 threads to write to the StdIn and read from StdOut of “ftp.exe”, and the output is like this:

Commands may be abbreviated.  Commands are:

Commands may be abbreviated.  Commands are:

Commands may be abbreviated.  Commands are:
....(exactly 16 times of above lines and then exactly 16 times of the following cmds list)
!              delete          literal         prompt          send
?              debug           ls              put             status
append         dir             mdelete         pwd             trace
...

and the last commands list is not even complete.

It seems that the help command output is divided into two parts.

The 1st part is:

Commands may be abbreviated.  Commands are:

The 2nd part is:

!              delete          literal         prompt          send
?              debug           ls              put             status
append         dir             mdelete         pwd             trace
...

And all the 1st parts are wrtten to the StdOut stream of “ftp.exe” before all the 2nd parts.
How coud this be?? Thanks for your comments.

I tested with other command of the “ftp.exe”, and it seems normal except the “help” command

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:55:27+00:00Added an answer on May 14, 2026 at 3:55 am

    The reason why you cannot get the input and output of http://ftp.exe is because the built-in http://ftp.exe from Microsoft Windows 2000/XP/Vista uses Console Input/Output.

    It is not simply a case of the ftp program not flushing its buffers.

    If you replace your invocation of http://ftp.exe with something like cmd.exe, you’ll see that it works fine. The problem is you are trying to read output where FTP is not sending it.
    You cannot use the regular approach to reading and writing to a child http://ftp.exe. This is a consequence of the implementation of that particular http://ftp.exe app.


    If you truly need to automate the built-in Windows ftp program, you will need to resort to pinvoke and the ReadConsoleOutput win32 function.

    Your alternatives are:

    • use a different ftp program. Likely they do not resort to the console I/O approach that the MS built-in program does
    • use an FTP class, like FtpWebRequest.
    • if that’s not appropriate or possible, use a low level network socket interface to FTP.

    see also: http://discuss.joelonsoftware.com/default.asp?design.4.332503.5

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 452k
  • Answers 452k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer WPF will ignore PropertyChanged events that are raised while it… May 15, 2026 at 9:14 pm
  • Editorial Team
    Editorial Team added an answer The awful, round about way to do it is to… May 15, 2026 at 9:14 pm
  • Editorial Team
    Editorial Team added an answer It could be because of the backslash preceding the codepoint… May 15, 2026 at 9:14 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.