public static UploaderFile[] CreateUploaders( this DirectoryInfo directoryHD, my.Ftp.DirectoryInfo directoryFTP, string searchPattern, bool recursive = false, CancellationTokenSource cancellation = null) { List <UploaderFile> uploaders = new List <UploaderFile>(); if (directoryHD.Exists) { foreach (FileInfo fileHD in directoryHD.GetFiles(searchPattern, recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly)) { UploaderFile uploderFile = fileHD.CreateUploader(directoryFTP); if (uploderFile != null) { uploaders.Add(uploderFile); } if (null != cancellation && cancellation.IsCancellationRequested) { throw new OperationCanceledException(); } } } return(uploaders.ToArray()); }
public static UploaderFile CreateUploader(this FileInfo fileHD, my.Ftp.DirectoryInfo fileFTP) { if (fileHD.Exists) { return(new UploaderFile( fileFTP: (my.Ftp.FileInfo) new my.Ftp.FileInfo((my.Ftp.DirectoryInfo)fileFTP, (string)fileHD.Name), fileHD: (System.IO.FileInfo)fileHD)); } else { return(null); } }
public static UploaderFile[] CreateUploaders(this IEnumerable <FileInfo> filesHD, my.Ftp.DirectoryInfo fileFTP) { List <UploaderFile> uploaders = new List <UploaderFile>(); foreach (FileInfo fleHD in filesHD) { if (fleHD.Exists) { uploaders.Add( new UploaderFile( fileFTP: (my.Ftp.FileInfo) new my.Ftp.FileInfo((my.Ftp.DirectoryInfo)fileFTP, (string)fleHD.Name), fileHD: (System.IO.FileInfo)fleHD) ); } } return(uploaders.ToArray()); }