示例#1
0
        /// <summary>
        /// Extracts all files to the given directory
        /// </summary>
        /// <param name="outputDirectory">Directory to which the files should be saved. This will be created if it does not exist.</param>
        /// <param name="fileSystem">File system to which to save the files</param>
        public async Task Extract(string outputDirectory, IFileSystem fileSystem, ProgressReportToken?progressReportToken = null)
        {
            if (!fileSystem.DirectoryExists(outputDirectory))
            {
                fileSystem.CreateDirectory(outputDirectory);
            }

            var filenames = GetFilenames();
            await AsyncFor.ForEach(filenames, filename =>
            {
                var fileData = GetFile(filename);
                if (fileData == null)
                {
                    return;
                }
                fileSystem.WriteAllBytes(Path.Combine(outputDirectory, filename), fileData);
            }, progressReportToken : progressReportToken).ConfigureAwait(false);
        }