locked
How to use DOS commands in C# RRS feed

  • Question

  • Hi All,

    Please tell how can i use the <ls ftp command> that is used for listing all the files in a directory in C#

    With Regards

    Bikram

    Tuesday, July 1, 2008 1:27 PM

All replies

  • ProcessStartInfo sinfo = new ProcessStartInfo("cmd", "/C dir")
    sinfo.RedirectStandardOutput = true;
    sinfo.UseShellExecute = false;
    sinfo.CreateNoWindow = true;
    Process p = new Process();
    p.StartInfo = sinfo;
    p.Start();
    String  output = p.StandardOutput.ReadToEnd();
    Console.Write(output);

    Hope this helps.  I'm currently trying to figure out how to pass multiple commands to a process without getting deadlocked.  I've tried synchronous and asynchronous execution with no luck.
    Saturday, July 19, 2008 7:17 AM