private async Task <int> GetRemoteFilesCount(FolderMapping mapping) { DateTime latestSync = await LatestSync(mapping); string remotePath = folderRoot + mapping.FriendlyName + "/" + DateTimeDirUtils.GetDirDateTimeString(latestSync) + "/"; List <FtpListItem> files = await client.GetRecursiveListing(remotePath); return(files.Count); }
private async Task <int> GetRemoteFilesCount(string[] friendlyNames) { for (int i = 0; i < friendlyNames.Length; i++) { DateTime latestSync = await LatestSync(friendlyNames[i]); friendlyNames[i] = folderRoot + friendlyNames[i] + "/" + DateTimeDirUtils.GetDirDateTimeString(latestSync) + "/"; } List <FtpListItem> files = await client.GetRecursiveListing(friendlyNames); return(files.Count); }
private async Task DownloadFolderImpl(FolderMapping mapping, ProgressBarStepper stepper) { DateTime latestSync = await LatestSync(mapping); string remotePath = folderRoot + mapping.FriendlyName + "/" + DateTimeDirUtils.GetDirDateTimeString(latestSync) + "/"; List <FtpListItem> remoteFiles = await client.GetRecursiveListing(remotePath); foreach (FtpListItem file in remoteFiles) { string clientSidePath = mapping.ClientSidePath + @"\" + file.FullName.Substring(remotePath.Length).Replace("/", @"\"); await client.DownloadFileAsync(clientSidePath, file.FullName, true, FtpVerify.Retry); File.SetLastWriteTime(clientSidePath, latestSync); progressUpdateAction.Invoke(stepper.Step()); } }
private async Task UploadFolderImpl(FolderMapping mapping, ProgressBarStepper stepper) { string[] files = GetLocalFiles(mapping.ClientSidePath); var filePaths = from f in files select f.Substring(mapping.ClientSidePath.Length); DateTime uploadDateTime = DirUtils.GetLatestFileWriteTimeInDir(mapping.ClientSidePath); string datetimeFolderString = DateTimeDirUtils.GetDirDateTimeString(uploadDateTime); string serverSideFolderPath = folderRoot + mapping.FriendlyName + "/" + datetimeFolderString; client.CreateDirectory(serverSideFolderPath); foreach (string file in filePaths) { string uploadPath = serverSideFolderPath + file.Replace(@"\", "/"); await client.UploadFileAsync(mapping.ClientSidePath + file, uploadPath, FtpExists.Overwrite, true, FtpVerify.Retry); progressUpdateAction.Invoke(stepper.Step()); } }