Skip to content

muriarte/FtpUtil

Repository files navigation

FtpUtil

.Net Client FTP Library (C#)
(There is another project called muriarte/FtpUtilTest which contains Unit and Integration testing for this project)

This project exposes a myFTP class providing methods to do the most common file and folder operations with an FTP Server.

##List of methods:

  • List<string> GetFileList(string fileSpec)
    Returns a list of filenames on the current FTP Server folder whose names meet the fileSpec parameter

  • List<myFTPFileInfo> GetFileListDetailed()
    Returns a list of myFTPFileInfo objects for each file on the current FTP Server folder

  • List<myFTPFileInfo> GetFileListDetailed(string fileSpec)
    Returns a list of myFTPFileInfo objects for each file on the current FTP Server folder whose names meet the fileSpec parameter

  • List<myFTPFileInfo> GetFileListDetailed(string fileSpec, bool forceRefresh)
    Returns a list of myFTPFileInfo objects for each file on the current FTP Server folder whose names meet the fileSpec parameter forcing a refresh of the fileInfo cache is forceRefresh is true

  • bool ChangeFolder(string folder)
    Changes the current FTP Server folder. The folder specified can be absolute if it begins with '/' o relative to the current FTP Server folder if begins with any other character

  • string GetCurrentFolder()
    Returns the path of current FTP Server folder

  • bool GetFile(string remoteFile, string localFile)
    Downloads a file located on FTP Server and saves it on a local file

  • string GetFileString(string remoteFile)
    Downloads a file located on FTP Server and returns its contents as a string

  • byte[] GetFileBinary(string remoteFile)
    Downloads a file located on FTP Server and returns its contents as a byte[] array

  • System.TimeSpan GetTimeDiff()
    Tries to calculate the time difference between the local system and the FTP Server

  • long GetFileSize(string filename)
    Returns the size of the specified file

  • bool DeleteFile(string filename)
    Deletes a file on the FTP Server

  • bool DeleteFolder(string folderName)
    Deletes a folder on the FTP Server

  • bool RenameFile(string filename, string newFilename)
    Renames a file on the FTP Server

  • DateTime GetFileDateTime(string filename)
    Returns the last changed time of a file on the FTP Server

  • bool UploadFileString(string remoteFilename, string contents)
    _Saves a file on the FTP Server with the specified text contents _

  • bool UploadFile(string localFilename, string remoteFilename)
    Uploads a file from the local system to the FTP Server

  • bool UploadFileBytes(string remoteFilename, byte[] fileContents)
    Saves a file on the FTP Server with the binary contents specified

  • bool CreateFolder(string newFolderName)
    Creates a folder on the FTP Server

##Methods (c#):


###Class Constructor:
myFTP(string server, string user, string password, string rootFolder)

Parameters:
server - The FTP server address
user - The FTP login user name
password - The FTP login password
rootFolder - The root folder of the user on the FTP Server

Example:
var ftp = new myFTP("ftp://example.com", "username", "password", rootFolder); List<string> fileList;
fileList=ftp.GetFileList(null);


About

.Net Client FTP Library (C#)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages