잠토의 잠망경

[C#] Console Redirection For FTP, Sort etc 본문

공부/C sharp

[C#] Console Redirection For FTP, Sort etc

잠수함토끼 2014. 8. 1. 00:29

Console Redirection을 일반적인 상황 dir ping 같은건 잘된다. 근데 ftp 처럼 표준 입력을 받는 것에 대해서는 될듯 안되서
미치기 일보 직전이었는데 드디어 찾았다.

이틀동안 삽질에 삽질을 통해서 역시 세상은 넓고 똑똑한 사람들 천지다라는걸 다시 느끼고 무지를 느낀다.

오늘도 한 수 배운다. 구글 Thank you

http://www.c-sharpcorner.com/forums/thread/124511/using-command-linecmd-exe.aspx

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
        private void button2_Click(object sender, EventArgs e)
        {
            Process p = new Process();
            p.StartInfo.FileName = @"C:\Windows\System32\ftp.exe";
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.RedirectStandardInput = true;
            p.StartInfo.UseShellExecute = false;
            try { p.Start(); }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return;
            }
 
 
            StreamWriter sw = p.StandardInput;
            sw.WriteLine("help");
            sw.WriteLine("bye");
            sw.Close();
            p.WaitForExit();
 
 
            this.richTextBox1.Text = p.StandardOutput.ReadToEnd();
        }

 

[예시]

 

[결론]

와우~~ 와우~~ 와우~~

 

 

 

Comments