4
Answers

FTP commands on CSharp

yokzu

yokzu

11y
2.4k
1
Hi,
I just want to send a file to an FTP server with csharp. Normally I am using these commands on cmd.exe

ftp 12.12.12.12
user
pass
put test.txt

and the file has been sent. But How can do it with Csharp? I tryed something below but it didnt work.

            string parametre1 = "/C ftp 12.12.12.12";
            string parametre2 = "/C username";
            string parametre3 = "/C password";
            string parametre4 = "/C put c:\test.txt";
            Process islem = new Process();
            islem.StartInfo.FileName = "C:\\Windows\\System32\\cmd.exe";
            islem.StartInfo.Arguments = parametre1;
            islem.StartInfo.Arguments = parametre2;
            islem.StartInfo.Arguments = parametre3;
            islem.StartInfo.Arguments = parametre4;
            islem.StartInfo.RedirectStandardOutput = true;
            islem.StartInfo.UseShellExecute = false;
            islem.Start();
            string output = islem.StandardOutput.ReadToEnd();
            islem.WaitForExit();
            textBox1.Text += output;
            islem.Close();

Answers (4)