如何将选定的文本文件发送到ftp服务器

问题描述:

我正在开发一个程序,将创建的文本文件发送到ftp服务器。

我以编程方式编写了文本文件并将其发送到另一个表单上的清单。

我在该清单上添加了一个按钮,将选中的文本文件发送到ftp服务器。



随意询问代码的任何部分,以便我可以给你你需要的东西。



我尝试过:



I'm working on a program that send a created text file to an ftp server.
I programmatically wrote the text file and sent the into a checklist on another form.
I added a button on that checklist to send the checked text files to the ftp server.

Feel free to ask about any part of the code so I can give you what you need.

What I have tried:

private void button1_Click(object sender, EventArgs e)
        {


            using (WebClient client = new WebClient())
            {
                client.Credentials = new NetworkCredential(ftpUsername, ftpPassword);
                client.UploadFile("ftp://ftpserver.com/target.zip", "STOR", localFilePath);
            }

            MessageBox.Show("sent textfile");
        }




FtpClient client = new FtpClient("server");

            client.Credentials = new NetworkCredential("id", "password");

            client.Connect();



如果有更好的方法将文件发送到ftp服务器我就可以了。我正在使用FluentFTP。


If there's a better way to send the files to the ftp server I'm ok with it. I'm using FluentFTP.

GitHub - FluentFTP [ ^ ]是一个很好的选择。维护良好,有很多关于如何使用链接的明确示例[ ^ ]。你需要的代码是他给出的第一个例子......
GitHub - FluentFTP[^] is an excellent choice. Well maintained, lots of clear examples of how to use with the link[^]. The code that you need is in the first example he gives...