Free FTP Library [closed]
Asked Answered
S

7

103

Can you recommend a free FTP library(class) for C#.

The class has to be well written, and have good performance.

Skimmia answered 3/9, 2009 at 7:44 Comment(0)
H
88

You may consider FluentFTP, previously known as System.Net.FtpClient.

It is released under The MIT License and available on NuGet (FluentFTP).

Hardcore answered 18/6, 2011 at 14:1 Comment(5)
THANK YOU!!! This really works very well! it lists directory with correct date time :)))) and its fast! sample code: FtpClient ftp = new FtpClient(txtUsername.Text, txtPassword.Text, txtFTPAddress.Text); FtpListItem[] items = ftp.GetListing();//here you can get list with type, name, modified date and other properties. FtpFile file = new FtpFile(ftp, "8051812.xml");//file to get file.Download("c:\\8051812.xml");//download file.Name = "8051814.xml";//change name to get new file.Download("c:\\8051814.xml"); ftp.Disconnect();//closeQuieten
Note that the compiled libraries are for .NET 3 but the code is trivial to convert to 2.0Incensory
Is is also available als NuGet package: System.Net.FtpClientRhizoid
True, but you can easily add your own extension methods to have the same syntax as before. Here are mine: pastebin.com/FiKMrH76Hardcore
While FluentFTP is indeed a good .NET FTP client library, it unfortunately does not support TLS/SSL session reuse. What is a severe limitation nowadays, when security is a must and many FTP server require the reuse. See Can connect to FTP using FileZilla or WinSCP, but not with FtpWebRequest or FluentFTP.Gowen
I
21

Why don't you use the libraries that come with the .NET framework: 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.

They were designed by Microsoft who no longer recommend that they should be used:

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://learn.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!

Inadvertent answered 23/2, 2010 at 15:16 Comment(10)
Im not 100% sure but doesn't those classes reconnect on each request? If that is the case then the performance would suffer..Hierarchize
The FtpWebRequest class only really works for simple, transactional FTP actions that can be modelled on the Request/Response pattern, such as downloading or uploading individual files. It's very difficult to use it to perform tasks like creating an FTP folder structure or upload and download in the same session.Domella
They require a lot of "plumbing" including parsing each response. It's a good start, but it's incomplete.Rapturous
"Should" is the operative word. It probably isn't worth your time to debug FtpWebRequest examples that only work in your unit tests.Decemvirate
There are apparently bugs (sorry for lack of source) in FtpWebFequest that cause issues when used with Mono .NETCasuist
Very... Bad component - you can't easy list files or folders, if you provide bad url - it will run without any exception, but will return html with message - I don't found any file (so, you need to parse that html)... I think microsoft can spend some time and create normal library and not this...Ersatz
@Ersatz : Good news! You can contribute to the development on github now! :-)Inadvertent
@0fnt: Your comment is like: you don't like this car - make yourself.Ersatz
FtpWebRequest still support only Explicit SSL. If you have to use Implicit SSL FtpWebRequest is not an option.Kroon
The MS documentation learn.microsoft.com/en-us/dotnet/api/… says not to use for new projects, and points to github.com/dotnet/platform-compat/blob/master/docs/DE0003.md which in turn points to this questionUnarmed
D
12

edtFTPnet is a free, fast, open source FTP library for .NET, written in C#.

Descant answered 15/2, 2010 at 11:52 Comment(3)
It's under LGPL license. So if you're developing commercial product/service you're opening that can of worms of what you can do and what you can't, what to include, etc. And multiple answers on SO and others give different opinions on that matter...Giotto
I'm one of the developers of this software. I thought I'd just chip in that we've never pursued anyone over LGPL violations or even thought to look for any such cases. The main reason we chose this license when the library was first published in 2003 was that LGPL was one of the only such widely known licenses around. There are many more options now and we should probably find another license that better suits our aim. The only thing we want to ensure is that no one uses our software to create a commercial product that competes with it. Anyone got suggestions for a less onerous license?Facilitate
By the way, if your legal people are ever worried about it, you can just purchase a more liberal license for $99. Oh, and also the website has been updated now :). The product is still very much alive, partly because it's a part of another very successful product, i.e. CompleteFTP. Thanks Oleksii for pointing out this problem. We'll discuss it.Facilitate
M
7

I like Alex FTPS Client which 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.

Mccormac answered 23/12, 2011 at 7:36 Comment(2)
Dead link. Did the project move somewhere else?Bethesda
Looks like this is their GitHub, but does not have any ftp repository.Bethesda
G
5

You could use the ones on CodePlex or http://www.enterprisedt.com/general/press/20060818.html

Gause answered 3/9, 2009 at 7:50 Comment(0)
E
1

I've just posted an article that presents both an FTP client class and an FTP user control.

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.

Ellette answered 10/3, 2011 at 17:15 Comment(3)
Uses the obsolete FtpWebRequestBethesda
@Kissaki: That's what can happen in answers that are over 11 years old.Ellette
What a shame this is closed due to "This question does not meet Stack Overflow guidelines." It needs updating very badly, as this issue has grown even more widely known and urgent. See github.com/dotnet/runtime/issues/27916 (updated through Nov 2020) which points to this 2018 post github.com/dotnet/platform-compat/blob/master/docs/DE0003.md which as noted above points HERE to this thread that's "dead" but useful enough for the .NET Core team to leave a pointer to it?Aslant
H
1

After lots of investigation in the same issue I found this one to be extremely convenient: 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:

  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);
        }
    }
Hypocrisy answered 27/11, 2013 at 18:7 Comment(2)
flagftp uses the Windows ftp client calls. This is not a good or bad thing but it does mean that the library is susceptible to the same errors that the windows ftp calls can throwGraecoroman
They do not disclose a license. Last version 0.1.3 from 2012. This is a dead, incomplete, unlicensed project.Bethesda

© 2022 - 2024 — McMap. All rights reserved.