Exemple #1
0
        /// <summary>
        /// オーディオファイルを変換する(複数)
        /// </summary>
        protected override void ConvertMultiFile()
        {
            var filePathes = InputPath.GetSpecifiedTypeFiles(SourceFileType);

            // 圧縮に時間がかかるので並列処理する
            var lockObject = new object();

            Parallel.ForEach(filePathes, filePath =>
            {
                (var input, var output) = PathUtility.CreateMediaFile(filePath, OutputPath, SourceFileType, DestinationFileType);
                lock ( lockObject )
                {
                    using (var engine = new Engine()) { engine.Convert(input, output); }
                    TargetFilePath = filePath;
                    Status         = Running;
                }
            });
            Status = Complete;
        }
Exemple #2
0
        /// <summary>
        /// ZIPファイルに変換する(複数)
        /// </summary>
        protected override void ConvertMultiFile()
        {
            using (var zip = ZipFile.Open(OutputPath, ZipArchiveMode.Update, Encoding.GetEncoding("shift_jis")))
            {
                var filePathes = InputPath.GetSpecifiedTypeFiles(SourceFileType);

                // 圧縮に時間がかかるので並列処理する
                var lockObject = new object();
                Parallel.ForEach(filePathes, filePath =>
                {
                    lock ( lockObject )
                    {
                        zip.CreateEntryFromFile(filePath, Path.GetFileName(filePath), CompressionLevel.Optimal);
                        TargetFilePath = filePath;
                        Status         = Running;
                    }
                });
                Status = Complete;
            }
        }