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; }
private void RecursiveDirectory(string dirPath, string uploadPath) { var files = Directory.GetFiles(dirPath, "*.*"); var subDirs = Directory.GetDirectories(dirPath); foreach (var file in files) { ftpManager.Upload(uploadPath + "/" + Path.GetFileName(file), file); } foreach (var subDir in subDirs) { ftpManager.CreateDirectory(uploadPath + "/" + Path.GetFileName(subDir)); RecursiveDirectory(subDir, uploadPath + "/" + Path.GetFileName(subDir)); } }