コード例 #1
0
        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());
        }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
        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());
        }