Example #1
0
        private void Watch()
        {
            if (!Directory.Exists(currentUser.Path))
            {
                Directory.CreateDirectory(currentUser.Path);
            }
            relatiavePath = client.GetUserDir();
            ftpManager    = new FtpManager(client.GetFtpHost(), client.GetFtpUser(), client.GetFtpPassword());
            ftpManager.CreateDirectory($@"UserDirectories{client.GetPath(currentUser)}");
            var url = "UserDirectories/28";

            ftpManager.DownloadFtpDirectory(url, Properties.Settings.Default.PutBoxDirectory);
            watcher = new FileSystemWatcher
            {
                IncludeSubdirectories = true,
                Path         = currentUser.Path,
                NotifyFilter =
                    NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName
                    | NotifyFilters.DirectoryName,
                Filter = "*.*",
                EnableRaisingEvents = true
            };
            watcher.Renamed += OnRenamed;
            watcher.Created += OnCreated;
            watcher.Deleted += OnDeleted;
        }
Example #2
0
        private void MenuItem_OnClick(object sender, RoutedEventArgs e)
        {
            switch ((sender as MenuItem).Header.ToString())
            {
            case "Synchronization":
                var url = $@"UserDirectories{client.GetPath(currentUser)}";
                ftpManager.DownloadFtpDirectory(url, Properties.Settings.Default.PutBoxDirectory);
                break;

            case "Options":
                var fbd = new FolderBrowserDialog();
                if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    fbd.Description = @"Choose empty folder or create new";
                    Properties.Settings.Default.PutBoxDirectory = fbd.SelectedPath;
                    Properties.Settings.Default.Save();
                }
                break;

            case "Sign Out":
                this.Close();
                break;
            }
        }