如何将选定的文本文件发送到ftp服务器 [英] How do I send selected textfiles to an ftp server
本文介绍了如何将选定的文本文件发送到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 [< a href =https://github.com/hgupta9/FluentFTPtarget =_ blanktitle =New Window> ^ ]是一个很好的选择。维护良好,有很多关于如何使用链接的明确示例[ ^ ]。你需要的代码是他给出的第一个例子......
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...
这篇关于如何将选定的文本文件发送到ftp服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文