C# Class Common.SyncHelper

Implements various methods involved in communication with an ftp server.
Afficher le fichier Open project: Revelations/BaconApp

Méthodes publiques

Méthode Description
CompareFileSize ( string fileName, string localDirectory = "", string remoteDirectory = "" ) : bool

Compares a local version of a file with its remote counterpart to check whether or not they are the same size.

CompareLastModified ( string fileName, string localDirectory = "", string remoteDirectory = "" ) : bool

Compares a local version of a file with its remote counterpart to check whether or not they have the same last modified date.

DeleteLocalFile ( string fileName, string localDirectory ) : void

Deletes a local file from the file system.

DeleteRemoteFile ( string fileName, string remoteDirectory = "" ) : void

Deletes a file from a remote FTP server.

DownloadFile ( string fileName, string localDirectory = "", string remoteDirectory = "" ) : void

Downloads a single file from a remote FTP server.

GetLocalDirectoryListing ( string directory = "" ) : List

Gets a list of files stored in a given local directory.

GetLocalDirectoryListing ( string directory, bool subdirectories ) : List
GetLocalFileSize ( string fileName, string localDirectory = "" ) : long?

Gets the size of a file stored on the local file system.

GetLocalLastModified ( string fileName, string localDirectory = "" ) : DateTime?

Gets the time at which a local file was last modified.

GetRemoteDirectoryListing ( ) : List

Gets a listing of all the files in the root directory of the FTP server.

GetRemoteDirectoryListing ( string subDirectory ) : List

Gets a listing of all the files in a subdirectory of the FTP server.

GetRemoteFileSize ( string fileName, string remoteDirectory = "" ) : long?

Gets the size of a file stored on the remote server.

GetRemoteLastModified ( string fileName, string remoteDirectory = "" ) : DateTime?

Gets the time at which a remote file was last modified.

LocalVersionExists ( string fileName, string localDirectory = "" ) : bool

Checks if there is a given file present on the local filesystem.

NeedsDownload ( string filename, string localDirectory = "", string remoteDirectory = "" ) : bool

Determines if a file needs to be downloaded, based on differences between the server and filesystem.

NeedsFeedbackDownload ( string filename, List files ) : bool

NeedsUpload ( string filename, List files, string localDirectory = "", string remoteDirectory = "" ) : bool

NeedsUpload ( string filename, string localDirectory = "", string remoteDirectory = "" ) : bool

Determines if a file needs to be downloaded, based on differences between the server and filesystem.

RemoteVersionExists ( string fileName, string remoteDirectory = "" ) : bool

Checks if there is a given file present on a remote FTP server.

UploadFile ( string fileName, string localDirectory = "", string remoteDirectory = "" ) : void

Uploads a single file to a remote FTP server.

Private Methods

Méthode Description
GetDirectoryDetails ( string directory, string method ) : List

Gets a directory listing from a remote server in a format according to the web request method used.

InitRequest ( string location, string method ) : FtpWebRequest

Initialises an FTPWebRequest to perform operations on a remote FTP server.

ItemIsFile ( string item ) : bool

Checks whether a specified string represents a file or a directory.

Method Details

CompareFileSize() public static méthode

Compares a local version of a file with its remote counterpart to check whether or not they are the same size.
public static CompareFileSize ( string fileName, string localDirectory = "", string remoteDirectory = "" ) : bool
fileName string Name of the file.
localDirectory string Directory that local version is stored in. Relative to working directory.
remoteDirectory string Directory that remote version is stored in.
Résultat bool

CompareLastModified() public static méthode

Compares a local version of a file with its remote counterpart to check whether or not they have the same last modified date.
public static CompareLastModified ( string fileName, string localDirectory = "", string remoteDirectory = "" ) : bool
fileName string Name of the file.
localDirectory string Directory that local version is stored in. Relative to working directory.
remoteDirectory string Directory that remote version is stored in.
Résultat bool

DeleteLocalFile() public static méthode

Deletes a local file from the file system.
public static DeleteLocalFile ( string fileName, string localDirectory ) : void
fileName string Name of the file to delete.
localDirectory string Directory relative to working directory that it is stored in.
Résultat void

DeleteRemoteFile() public static méthode

Deletes a file from a remote FTP server.
public static DeleteRemoteFile ( string fileName, string remoteDirectory = "" ) : void
fileName string Name of the file to delete.
remoteDirectory string Optional subdirectory it is located in.
Résultat void

DownloadFile() public static méthode

Downloads a single file from a remote FTP server.
public static DownloadFile ( string fileName, string localDirectory = "", string remoteDirectory = "" ) : void
fileName string Name of the file to download.
localDirectory string Directory relative to the working directory to store it in once downloaded.
remoteDirectory string Subdirectory the file is located in on the server.
Résultat void

GetLocalDirectoryListing() public static méthode

Gets a list of files stored in a given local directory.
public static GetLocalDirectoryListing ( string directory = "" ) : List
directory string Optional subdirectory to retrieve list for instead.
Résultat List

GetLocalDirectoryListing() public static méthode

public static GetLocalDirectoryListing ( string directory, bool subdirectories ) : List
directory string
subdirectories bool
Résultat List

GetLocalFileSize() public static méthode

Gets the size of a file stored on the local file system.
public static GetLocalFileSize ( string fileName, string localDirectory = "" ) : long?
fileName string Name of the file.
localDirectory string Directory it is located in. Relative to the working directory.
Résultat long?

GetLocalLastModified() public static méthode

Gets the time at which a local file was last modified.
public static GetLocalLastModified ( string fileName, string localDirectory = "" ) : DateTime?
fileName string Name of the file.
localDirectory string Directory it is located in. Relative to the working directory.
Résultat DateTime?

GetRemoteDirectoryListing() public static méthode

Gets a listing of all the files in the root directory of the FTP server.
public static GetRemoteDirectoryListing ( ) : List
Résultat List

GetRemoteDirectoryListing() public static méthode

Gets a listing of all the files in a subdirectory of the FTP server.
public static GetRemoteDirectoryListing ( string subDirectory ) : List
subDirectory string Name of the subdirectory to index.
Résultat List

GetRemoteFileSize() public static méthode

Gets the size of a file stored on the remote server.
public static GetRemoteFileSize ( string fileName, string remoteDirectory = "" ) : long?
fileName string Name of the file.
remoteDirectory string Directory it is located in. Relative to the root directory.
Résultat long?

GetRemoteLastModified() public static méthode

Gets the time at which a remote file was last modified.
public static GetRemoteLastModified ( string fileName, string remoteDirectory = "" ) : DateTime?
fileName string Name of the file.
remoteDirectory string Directory it is located in. Relative to the root directory.
Résultat DateTime?

LocalVersionExists() public static méthode

Checks if there is a given file present on the local filesystem.
public static LocalVersionExists ( string fileName, string localDirectory = "" ) : bool
fileName string Name of the file.
localDirectory string Directory it is located in. Relative to working directory.
Résultat bool

NeedsDownload() public static méthode

Determines if a file needs to be downloaded, based on differences between the server and filesystem.
public static NeedsDownload ( string filename, string localDirectory = "", string remoteDirectory = "" ) : bool
filename string Name of the file.
localDirectory string Optional additional directory it is stored in.
remoteDirectory string Directory it is located in on the server.
Résultat bool

NeedsFeedbackDownload() public static méthode

public static NeedsFeedbackDownload ( string filename, List files ) : bool
filename string
files List
Résultat bool

NeedsUpload() public static méthode

public static NeedsUpload ( string filename, List files, string localDirectory = "", string remoteDirectory = "" ) : bool
filename string
files List
localDirectory string
remoteDirectory string
Résultat bool

NeedsUpload() public static méthode

Determines if a file needs to be downloaded, based on differences between the server and filesystem.
public static NeedsUpload ( string filename, string localDirectory = "", string remoteDirectory = "" ) : bool
filename string Name of the file.
localDirectory string Optional additional directory it is stored in.
remoteDirectory string Directory it is located in on the server.
Résultat bool

RemoteVersionExists() public static méthode

Checks if there is a given file present on a remote FTP server.
public static RemoteVersionExists ( string fileName, string remoteDirectory = "" ) : bool
fileName string Name of the file.
remoteDirectory string Remote subdirectory it resides in.
Résultat bool

UploadFile() public static méthode

Uploads a single file to a remote FTP server.
public static UploadFile ( string fileName, string localDirectory = "", string remoteDirectory = "" ) : void
fileName string Name of the file.
localDirectory string Directory relative to the working directory that file is currently stored in.
remoteDirectory string Remote directory to store the file in once uploaded.
Résultat void