Ejemplo n.º 1
0
        private List <FileForSign> GetAllFilesFromPathes(List <String> pathes)
        {
            if (pathes.Count >= 1)
            {
                var sourceFilePathes = new List <string>();
                foreach (var path in pathes)
                {
                    //папка
                    if (Directory.Exists(path))
                    {
                        sourceFilePathes.AddRange(Directory.GetFiles(path, "*", SearchOption.AllDirectories).ToList());
                        CurrentDirectory = path;
                    }
                    //файл
                    else if (File.Exists(path))
                    {
                        sourceFilePathes.Add(path);
                        CurrentDirectory = path;
                    }
                }

                var fileExs = new List <FileEx>();
                foreach (var sourceFilePath in sourceFilePathes)
                {
                    var fileExtension       = Path.GetExtension(sourceFilePath);
                    var lowredFileExtension = fileExtension != null?fileExtension.ToLower() : null;

                    if (lowredFileExtension != null && lowredFileExtension.Equals(QuickSignum.SignExtension))
                    {
                        continue;
                    }

                    var isZipFile = lowredFileExtension != null && lowredFileExtension.Equals(".zip");
                    if (SignInZip && isZipFile)
                    {
                        var createdFileExs = FileEx.CreateFileExs(sourceFilePath, FileEx.FileType.Zip);
                        fileExs.AddRange(createdFileExs);
                    }
                    else
                    {
                        var createdFileExs = FileEx.CreateFileExs(sourceFilePath, FileEx.FileType.File);
                        fileExs.AddRange(createdFileExs);
                    }
                }


                var filesForSign = fileExs.Select(f => new FileForSign(f))
                                   .Where(f => !f.Extension.ToLowerInvariant().Equals(QuickSignum.SignExtension.ToLowerInvariant()))
                                   .ToList();
                if (filesForSign.Count > 0)
                {
                    return(filesForSign);
                }
            }

            MessageBox.Show("Не найдено ни одного файла для подписи");
            return(new List <FileForSign>());
        }