C# Class Common.SyncHelper

Implements various methods involved in communication with an ftp server.
Show file Open project: Revelations/BaconApp

Public Methods

Method 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

Method 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 method

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.
return bool

CompareLastModified() public static method

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.
return bool

DeleteLocalFile() public static method

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.
return void

DeleteRemoteFile() public static method

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.
return void

DownloadFile() public static method

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.
return void

GetLocalDirectoryListing() public static method

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.
return List

GetLocalDirectoryListing() public static method

public static GetLocalDirectoryListing ( string directory, bool subdirectories ) : List
directory string
subdirectories bool
return List

GetLocalFileSize() public static method

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.
return long?

GetLocalLastModified() public static method

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.
return DateTime?

GetRemoteDirectoryListing() public static method

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

GetRemoteDirectoryListing() public static method

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.
return List

GetRemoteFileSize() public static method

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.
return long?

GetRemoteLastModified() public static method

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.
return DateTime?

LocalVersionExists() public static method

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.
return bool

NeedsDownload() public static method

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.
return bool

NeedsFeedbackDownload() public static method

public static NeedsFeedbackDownload ( string filename, List files ) : bool
filename string
files List
return bool

NeedsUpload() public static method

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

NeedsUpload() public static method

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.
return bool

RemoteVersionExists() public static method

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.
return bool

UploadFile() public static method

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.
return void