Giter Site home page Giter Site logo

ftp's Introduction

Arx One FTP

A simple FTP/FTPS/FTPES client. The client handles multiple connections and is thread safe. It also has high-level commands but supports direct command sending.

Suggestions, requests, love letters...

We are open to suggestions, don't hesitate to submit one.

How to get it

As a NuGet package.

How to use it

Instantiation

using (var ftpClient = new FtpClient(ftpUri, ftpCredentials))
{
    // ... Enjoy!
}

Commands

High-level commands

They are implemented in the form of extension methods to FtpClient

  • IList<string> List(this FtpClient ftpClient, FtpPath path) lists a directory content and returns raw lines.
  • IEnumerable<FtpEntry> ListEntries(this FtpClient ftpClient, FtpPath path) lists a directory content and returns parsed entries.
  • IEnumerable<string> Stat(this FtpClient ftpClient, FtpPath path) lists a directory content using the STAT command and returns raw lines.
  • IEnumerable<FtpEntry> StatEntries(this FtpClient ftpClient, FtpPath path) lists a directory using the STAT command and returns parsed entries.
  • Stream Retr(this FtpClient ftpClient, FtpPath path, FtpTransferMode mode = FtpTransferMode.Binary) opens a file for downloading
  • Stream Stor(this FtpClient ftpClient, FtpPath path) creates a file for uploading
  • bool Rmd(this FtpClient ftpClient, FtpPath path) removes the directory
  • bool Dele(this FtpClient ftpClient, FtpPath path) removes the file
  • bool Delete(this FtpClient ftpClient, FtpPath path) removes the entry, whenever it is a file or directory
  • void RnfrTo(this FtpClient ftpClient, FtpPath from, FtpPath to) renames/moves a file/directory
  • FtpEntry GetEntry(this FtpClient ftpClient, FtpPath path) gets informations about a file or directory
  • IList<string> Mlst(this FtpClient ftpClient, FtpPath path) gets a file status (raw form).
  • FtpEntry MlstEntry(this FtpClient ftpClient, FtpPath path) gets a file status
  • IList<string> Mlsd(this FtpClient ftpClient, FtpPath path) lists a directory content and returns raw lines.
  • IEnumerable<FtpEntry> MlsdEntries(this FtpClient ftpClient, FtpPath path) lists a directory content and returns parsed Note that all commands use an FtpPath instance, which has an automatic implicit constructor from string, so you can just use strings as parameters, the implicit conversion will do the trick.

Core commands

For the hard-core developpers, here are some useful low-level commands. First of all, it is necessary to understand that the FtpClient instance can handle multiple connections at the same time (thus, it uses one separate connection to send one command). Usually it uses only one session, and reuses it command after command. You don't manipulate sessions directly but they are used by the client).

  • bool Features.HasFeature(string feature) indicates if a feature is supported by the server (the method is a method from the Features member of FtpClient)
  • FtpSession Session() uses or create a session (this allows mutiple connections at same time with only one FtpClient)
  • FtpReply SendCommand(FtpSessionHandle session, string command, params string[] parameters) sends a command and returns a raw FTP reply
  • FtpReply Expect(FtpReply reply, params int[] codes) expects the given reply to have one of the given codes.

For example:

// main connection to target
using (var ftpClient = new FtpClient(new Uri("ftp://server"), new NetworkCredential("anonymous","[email protected]")))
{
    // using or creating a session
    using(var ftpSession = ftpClient.Session())
    {
        // sending a custom command
        var ftpReply = ftpSession.SendCommand("STUFF", "here", "now");
        // checkin the result. The Expect method returns the FtpReply, so SendCommand() and Expect() can be nested.
        FtpSession.Expect(ftpReply, 200, 250);
    }
}

ftp's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.