C# 免费 FTP 库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1371964/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Free FTP Library
提问by
Can you recommend a free FTP library(class) for C#.
您能否为 C# 推荐一个免费的 FTP 库(类)。
The class has to be well written, and have good performance.
这门课必须写得很好,并且有很好的表现。
回答by Kane
You could use the ones on CodePlexor http://www.enterprisedt.com/general/press/20060818.html
您可以使用CodePlex或http://www.enterprisedt.com/general/press/20060818.html上的那些
回答by Bruce Blackshaw
回答by 0fnt
Why don't you use the libraries that come with the .NET framework: http://msdn.microsoft.com/en-us/library/ms229718.aspx?
为什么不使用 .NET 框架附带的库:http: //msdn.microsoft.com/en-us/library/ms229718.aspx?
EDIT: 2019 April by https://stackoverflow.com/users/1527/This answer is no longer valid. Other answers are endorsed by Microsoft.
编辑:2019 年 4 月,作者:https://stackoverflow.com/users/1527/ 此答案不再有效。其他答案得到了微软的认可。
They were designed by Microsoft who no longer recommend that they should be used:
它们是由 Microsoft 设计的,不再建议使用它们:
We don't recommend that you use the FtpWebRequest class for new development. For more information and alternatives to FtpWebRequest, see WebRequest shouldn't be used on GitHub. (https://docs.microsoft.com/en-us/dotnet/api/system.net.ftpwebrequest?view=netframework-4.7.2)
我们不建议您使用 FtpWebRequest 类进行新的开发。有关 FtpWebRequest 的更多信息和替代方法,请参阅 GitHub 上不应使用 WebRequest。( https://docs.microsoft.com/en-us/dotnet/api/system.net.ftpwebrequest?view=netframework-4.7.2)
The 'WebRequest shouldn't be used' page in turn points to this question as the definitive list of libraries!
“不应使用 WebRequest”页面又将这个问题作为库的最终列表!
回答by Jonathan Wood
I've just posted an articlethat presents both an FTP client class and an FTP user control.
我刚刚发表了一篇文章,介绍了 FTP 客户端类和 FTP 用户控件。
They are simple and aren't very fast, but are very easy to use and all source code is included. Just drop the user control onto a form to allow users to navigate FTP directories from your application.
它们很简单,速度也不是很快,但非常易于使用,并且包含所有源代码。只需将用户控件拖放到表单上,即可允许用户从您的应用程序中导航 FTP 目录。
回答by Erwin Mayer
You may consider FluentFTP, previously known as System.Net.FtpClient.
您可以考虑FluentFTP,以前称为System.Net.FtpClient。
It is released under The MIT Licenseand available on NuGet (FluentFTP).
它是在The MIT License下发布的,可在 NuGet (FluentFTP) 上使用。
回答by John C
I like Alex FTPS Clientwhich is written by a Microsoft MVP name Alex Pilotti. It's a C# library you can use in Console apps, Windows Forms, PowerShell, ASP.NET (in any .NET language). If you have a multithreaded app you will have to configure the library to run syncronously, but overall a good client that will most likely get you what you need.
我喜欢Alex FTPS 客户端,它由 Microsoft MVP 名称 Alex Pilotti 编写。它是一个 C# 库,您可以在控制台应用程序、Windows 窗体、PowerShell、ASP.NET(任何 .NET 语言)中使用。如果您有一个多线程应用程序,则必须将库配置为同步运行,但总体而言,这是一个很好的客户端,很可能会满足您的需求。
回答by Stephan
After lots of investigation in the same issue I found this one to be extremely convenient: https://github.com/flagbug/FlagFtp
在对同一问题进行大量调查后,我发现这个非常方便:https: //github.com/flagbug/FlagFtp
For example (try doing this with the standard .net "library" - it will be a real pain) -> Recursively retreving all files on the FTP server:
例如(尝试使用标准的 .net“库”执行此操作 - 这将是一个真正的痛苦)-> 递归检索 FTP 服务器上的所有文件:
public IEnumerable<FtpFileInfo> GetFiles(string server, string user, string password)
{
var credentials = new NetworkCredential(user, password);
var baseUri = new Uri("ftp://" + server + "/");
var files = new List<FtpFileInfo>();
AddFilesFromSubdirectory(files, baseUri, credentials);
return files;
}
private void AddFilesFromSubdirectory(List<FtpFileInfo> files, Uri uri, NetworkCredential credentials)
{
var client = new FtpClient(credentials);
var lookedUpFiles = client.GetFiles(uri);
files.AddRange(lookedUpFiles);
foreach (var subDirectory in client.GetDirectories(uri))
{
AddFilesFromSubdirectory(files, subDirectory.Uri, credentials);
}
}