Beispiel #1
1
 public Repository(string ftpServer, FtpUserCredentials credentials, LocalFolder localFolder)
 {
     _ftpAdress = ftpServer;
     _credentials = credentials;
     _localFolder = localFolder;
 }
Beispiel #2
0
        static void Main(string[] args)
        {
            // Read the config file for ftp settings
            string ftp_userName = ConfigurationManager.AppSettings["ftp_user"];
            string ftp_password = ConfigurationManager.AppSettings["ftp_password"];
            string ftp_adress = ConfigurationManager.AppSettings["ftp_adress"];
            string fileExtension = ConfigurationManager.AppSettings["fileExtension"];
            List<String> extensionsAllowed = new List<string>();
            extensionsAllowed.Add(fileExtension);

            // Read the config file for local path and misc settings
            string localDirectoryPath = ConfigurationManager.AppSettings["localDirectory"];

            LocalFolder folder = new LocalFolder();
            folder.Path = localDirectoryPath;
            folder.fileExtensionsAllowed = extensionsAllowed;
            FtpUserCredentials credentials = new FtpUserCredentials(ftp_userName, ftp_password);
            Repository repository = new Repository(ftp_adress, credentials, folder);

            bool running = true;

            Console.WriteLine("Start syncing local directory with ftp server directory");
            while (running)
            {
                repository.Sync();
                Thread.Sleep(60000 * 10); // sync every 10 minutes
            }
            Console.WriteLine("Exiting ftp sync");
        }