• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Compression.ZipArchiveEntry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.IO.Compression.ZipArchiveEntry的典型用法代码示例。如果您正苦于以下问题:C# ZipArchiveEntry类的具体用法?C# ZipArchiveEntry怎么用?C# ZipArchiveEntry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ZipArchiveEntry类属于System.IO.Compression命名空间,在下文中一共展示了ZipArchiveEntry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AddUpdateDeleteInventories

        private static void AddUpdateDeleteInventories(ZipArchiveEntry inventoriesEntry)
        {
            Console.WriteLine("inventories.csv is {0} bytes", inventoriesEntry.Length);
            IEnumerable<Inventory> inventories = null;

            using (var entryStream = inventoriesEntry.Open())
            {
                Console.WriteLine("Starting inventories at {0:hh:mm:ss.fff}", DateTime.Now);
                var stopwatch = new Stopwatch();
                stopwatch.Start();

                var reader = new StreamReader(entryStream);
                var csv = new CsvReader(reader);
                csv.Configuration.RegisterClassMap(new InventoryMap());
                StringBuilder invForImport = new StringBuilder();
                inventories = csv.GetRecords<Inventory>().Where(i => !i.IsDead);

                var inventoryCollection = new InventoryCollection();
                inventoryCollection.SetItems(inventories);
                var importer = new NpgsqlBulkImporter(ConfigurationManager.ConnectionStrings["spurious"].ConnectionString, stopwatch);
                importer.BulkImport("inventories", inventoryCollection);

                stopwatch.Stop();
                Console.WriteLine("Finished inventories at {0:hh:mm:ss.fff}, taking {1}", DateTime.Now, stopwatch.Elapsed);
            }
        }
开发者ID:claq2,项目名称:Spurious,代码行数:26,代码来源:Program.cs


示例2: AreHashEqual

 private static bool AreHashEqual(FileInfo existing, ZipArchiveEntry duplicate)
 {
     byte[] originalHash;
     byte[] otherHash;
     try
     {
         using (FileStream original = File.Open(existing.FullName, FileMode.Open, FileAccess.Read))
         {
             if (null == (originalHash = HashFile(original))) { return false; }
         }
         using (Stream other = duplicate.Open())
         {
             if (null == (otherHash = HashFile(other))) { return false; }
         }
         if (originalHash.Length == otherHash.Length)
         {
             for (int index = 0; index < originalHash.Length; index++)
             {
                 if (originalHash[index] != otherHash[index])
                 {
                     WriteError("Hashes don't match.");
                     return false;
                 }
             }
             return true;
         }
         return false;
     }
     catch (Exception e)
     {
         WriteError("Error while trying to compare hash. Error {0}",
             e.Message);
         return false;
     }
 }
开发者ID:BlueSkeye,项目名称:ApkRe,代码行数:35,代码来源:Program.cs


示例3: Process

 internal static string Process(ZipArchiveEntry packageFile, IMSBuildNuGetProjectSystem msBuildNuGetProjectSystem)
 {
     using (var stream = packageFile.Open())
     {
         return Process(stream, msBuildNuGetProjectSystem, throwIfNotFound: false);
     }
 }
开发者ID:pabomex,项目名称:NuGet.PackageManagement,代码行数:7,代码来源:PreProcessor.cs


示例4: WriteZipArchiveEntry

 static void WriteZipArchiveEntry(ZipArchiveEntry entry, string toWrite)
 {
     using (StreamWriter writer = new StreamWriter(entry.Open()))
     {
         writer.Write(toWrite);
     }
 }
开发者ID:GoogleFrog,项目名称:Zero-K-Infrastructure,代码行数:7,代码来源:MissionUpdater.cs


示例5: BuildZipFile

        /// <summary>
        /// Builds the zip file.
        /// </summary>
        /// <param name="updatesDirectory">The updates directory.</param>
        /// <param name="folderName">Name of the folder.</param>
        /// <param name="zipArchive">The zip archive.</param>
        /// <param name="zipArchiveEntry">The zip archive entry.</param>
        public void BuildZipFile(
            string updatesDirectory, 
            string folderName, 
            ZipArchive zipArchive, 
            ZipArchiveEntry zipArchiveEntry)
        {
            ////TraceService.WriteLine("ZipperService::BuildZipFile");

            string fullName = zipArchiveEntry.FullName;

            ////TraceService.WriteLine("Processing " + fullName);

            if (fullName.ToLower().StartsWith(folderName.ToLower()) &&
                fullName.ToLower().EndsWith(".dll"))
            {
                //// we have found one of the assemblies
                TraceService.WriteLine("Found assembley " + fullName);

                //// first look to see if we have a replacement
                string newFilePath = updatesDirectory + @"\" + zipArchiveEntry.Name;

                bool exists = this.fileSystem.File.Exists(newFilePath);

                if (exists)
                {
                    this.UpdateFile(zipArchive, zipArchiveEntry, fullName, newFilePath);
                }
                else
                {
                    TraceService.WriteLine(newFilePath + " does not exist");
                }
            }
        }
开发者ID:RobGibbens,项目名称:NinjaCoderForMvvmCross,代码行数:40,代码来源:ZipperService.cs


示例6: PackageEntry

 public PackageEntry(ZipArchiveEntry zipArchiveEntry)
 {
     FullName = zipArchiveEntry.FullName;
     Name = zipArchiveEntry.Name;
     Length = zipArchiveEntry.Length;
     CompressedLength = zipArchiveEntry.CompressedLength;
 }
开发者ID:jinujoseph,项目名称:NuGet.Services.Metadata,代码行数:7,代码来源:PackageEntriesStage.cs


示例7: ParseRouteCSV

        /// <summary>
        /// Reads a ZipArchive entry as the routes CSV and extracts the route colors.
        /// </summary>
        private static List<GoogleRoute> ParseRouteCSV(ZipArchiveEntry entry)
        {
            var routes = new List<GoogleRoute>();

            using (var reader = new StreamReader(entry.Open()))
            {
                // Ignore the format line
                reader.ReadLine();

                while (!reader.EndOfStream)
                {
                    var parts = reader.ReadLine().Split(',');

                    // Ignore all routes which aren't part of CTS and thus don't have any real-time data.
                    if (parts[0].Contains("ATS") || parts[0].Contains("PC") || parts[0].Contains("LBL"))
                    {
                        continue;
                    }

                    routes.Add(new GoogleRoute(parts));
                }
            }

            return routes;
        }
开发者ID:RikkiGibson,项目名称:Corvallis-Bus-Server,代码行数:28,代码来源:GoogleTransitClient.cs


示例8: AddUpdateDeleteStores

        private static void AddUpdateDeleteStores(ZipArchiveEntry entry)
        {
            IEnumerable<Store> stores = null;

            using (var entryStream = entry.Open())
            {
                Console.WriteLine("stores.csv is {0} bytes", entry.Length);
                Console.WriteLine("Starting stores at {0:hh:mm:ss.fff}", DateTime.Now);
                var storeTimer = new Stopwatch();
                storeTimer.Start();
                var reader = new StreamReader(entryStream);
                var csv = new CsvReader(reader);
                csv.Configuration.RegisterClassMap(new StoreMap());
                stores = csv.GetRecords<Store>().Where(s => !s.IsDead);

                var storesCollection = new StoreCollection();
                storesCollection.SetItems(stores);
                var importer = new NpgsqlBulkImporter(ConfigurationManager.ConnectionStrings["spurious"].ConnectionString, storeTimer);
                importer.BulkImport("stores", storesCollection);

                using (var wrapper = new NpgsqlConnectionWrapper(ConfigurationManager.ConnectionStrings["spurious"].ConnectionString))
                {
                    wrapper.Connection.Open();
                    var rowsGeoUpdated = wrapper.ExecuteNonQuery("update stores s set (location) = ((select ST_SetSRID(ST_MakePoint(longitude, latitude), 4326) from stores ss where s.id = ss.id))");
                    Console.WriteLine($"Updated {rowsGeoUpdated} rows geo data from lat/long data");
                }

                storeTimer.Stop();
                Console.WriteLine("Finished stores at {0:hh:mm:ss.fff}, taking {1}", DateTime.Now, storeTimer.Elapsed);
            }
        }
开发者ID:claq2,项目名称:Spurious,代码行数:31,代码来源:Program.cs


示例9: UnzipZipArchiveEntryAsync

        /// <summary>
        /// Unzips ZipArchiveEntry asynchronously.
        /// </summary>
        /// <param name="entry">The entry which needs to be unzipped</param>
        /// <param name="filePath">The entry's full name</param>
        /// <param name="unzipFolder">The unzip folder</param>
        /// <returns></returns>
        private static async Task UnzipZipArchiveEntryAsync(ZipArchiveEntry entry, string filePath, StorageFolder unzipFolder)
        {
            if (IfPathContainDirectory(filePath))
            {
                // Create sub folder
                string subFolderName = Path.GetDirectoryName(filePath);

                bool isSubFolderExist = await IfFolderExistsAsync(unzipFolder, subFolderName);

                StorageFolder subFolder;

                if (!isSubFolderExist)
                {
                    // Create the sub folder.
                    subFolder =
                        await unzipFolder.CreateFolderAsync(subFolderName, CreationCollisionOption.ReplaceExisting);
                }
                else
                {
                    // Just get the folder.
                    subFolder =
                        await unzipFolder.GetFolderAsync(subFolderName);
                }

                // All sub folders have been created yet. Just pass the file name to the Unzip function.
                string newFilePath = Path.GetFileName(filePath);

                if (!string.IsNullOrEmpty(newFilePath))
                {
                    // Unzip file iteratively.
                    await UnzipZipArchiveEntryAsync(entry, newFilePath, subFolder);
                }
            }
            else
            {

                // Read uncompressed contents
                using (Stream entryStream = entry.Open())
                {
                    byte[] buffer = new byte[entry.Length];
                    entryStream.Read(buffer, 0, buffer.Length);

                    // Create a file to store the contents
                    StorageFile uncompressedFile = await unzipFolder.CreateFileAsync
                    (entry.Name, CreationCollisionOption.ReplaceExisting);

                    // Store the contents
                    using (IRandomAccessStream uncompressedFileStream =
                    await uncompressedFile.OpenAsync(FileAccessMode.ReadWrite))
                    {
                        using (Stream outstream = uncompressedFileStream.AsStreamForWrite())
                        {
                            outstream.Write(buffer, 0, buffer.Length);
                            outstream.Flush();
                        }
                    }
                }
            }
        }
开发者ID:KeesPolling,项目名称:Popmail,代码行数:66,代码来源:FileUtils.cs


示例10: WrappedStream

 private WrappedStream(Stream baseStream, Boolean closeBaseStream, ZipArchiveEntry entry, Action<ZipArchiveEntry> onClosed)
 {
     _baseStream = baseStream;
     _closeBaseStream = closeBaseStream;
     _onClosed = onClosed;
     _zipArchiveEntry = entry;
     _isDisposed = false;
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:8,代码来源:ZipCustomStreams.cs


示例11: Extract

 private async Task Extract(ZipArchiveEntry entry, string basePath)
 {
     var fn = Path.Combine(basePath, entry.FullName);
     using (var fstream = File.Create(fn))
     {
         await entry.Open().CopyToAsync(fstream);
     }
 }
开发者ID:hosiminn,项目名称:StarryEyes,代码行数:8,代码来源:ReleaseActions.cs


示例12: CompressedArchiveFile

        /// <summary>
        /// Constructor.
        /// </summary>
        public CompressedArchiveFile(ZipArchiveEntry entry, int stripInitialFolders)
        {
            if (!entry.IsFile())
                throw new InvalidOperationException("Not a file.");

            _entry = entry;
            _stripInitialFolders = stripInitialFolders;
        }
开发者ID:CSClassroom,项目名称:CSClassroom,代码行数:11,代码来源:CompressedArchiveFile.cs


示例13: DeflateManagedStream

        // A specific constructor to allow decompression of Deflate64
        internal DeflateManagedStream(Stream stream, ZipArchiveEntry.CompressionMethodValues method)
        {
            if (stream == null)
                throw new ArgumentNullException(nameof(stream));
            if (!stream.CanRead)
                throw new ArgumentException(SR.NotSupported_UnreadableStream, nameof(stream));

            InitializeInflater(stream, false, null, method);
        }
开发者ID:dotnet,项目名称:corefx,代码行数:10,代码来源:DeflateManagedStream.cs


示例14: OnDoubleClick

 private void OnDoubleClick(object sender, MouseButtonEventArgs e)
 {
     var listBox = sender as ListBox;
     if (listBox.SelectedItem != null)
     {
         Result = listBox.SelectedItem as ZipArchiveEntry;
         Close();
     }
 }
开发者ID:prescottadam,项目名称:samples.ZipArchives,代码行数:9,代码来源:ExtractFileWindow.xaml.cs


示例15: ZipWrappingStream

 public ZipWrappingStream(ZipArchiveEntry zipArchiveEntry, Stream stream, FileMode packageFileMode, FileAccess packageFileAccess, bool canRead, bool canWrite)
 {
     _zipArchiveEntry = zipArchiveEntry;
     _baseStream = stream;
     _packageFileMode = packageFileMode;
     _packageFileAccess = packageFileAccess;
     _canRead = canRead;
     _canWrite = canWrite;
 }
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:9,代码来源:ZipWrappingStream.cs


示例16: GedcomxFileEntry

        /// <summary>
        /// Initializes a new instance of the <see cref="GedcomxFileEntry"/> class.
        /// </summary>
        /// <param name="entry">The zip archive this file belongs to.</param>
        /// <param name="attributes">The attributes belonging to this file (such as content type, etc).</param>
        /// <exception cref="System.ArgumentNullException">Thrown if the entry parameter is <c>null</c>.</exception>
        public GedcomxFileEntry(ZipArchiveEntry entry, List<ManifestAttribute> attributes)
        {
            if (entry == null)
            {
                throw new ArgumentNullException("entry");
            }

            this.zipEntry = entry;
            this.attributes = attributes;
        }
开发者ID:Herbert42,项目名称:gedcomx-csharp,代码行数:16,代码来源:GedcomxFileEntry.cs


示例17: FilterNewXapContent

        /// <summary>
        ///     Filters out the undesired entries from the copying process when calling CopyZipEntries method.
        /// </summary>
        /// <param name="entry">ZipArchiveEntry to filter.</param>
        /// <returns>True if entry should be included in the archive.</returns>
        private bool FilterNewXapContent(ZipArchiveEntry entry)
        {
            if (StringComparer.OrdinalIgnoreCase.Equals(entry.FullName, "AppManifest.xaml"))
                return false;

            if (_deletedEntries.Contains(entry.FullName))
                return false;

            return true;
        }
开发者ID:Thorarin,项目名称:XapReduce,代码行数:15,代码来源:RecreatedXapFile.cs


示例18: CopyStream

 private static void CopyStream(ZipArchiveEntry entry, MemoryStream ms)
 {
     var buffer = new byte[16*1024 - 1];
     int read;
     var stream = entry.Open();
     while ((read = stream.Read(buffer, 0, buffer.Length)) > 0)
     {
         ms.Write(buffer, 0, read);
     }
 }
开发者ID:Martin-Andreev,项目名称:Team-Billy_Buttons-SupermarketsChain,代码行数:10,代码来源:ImportFromExcel.cs


示例19: ArchiveFile

        public ArchiveFile(string abstractPath, ZipArchiveEntry entry)
        {
            // для работы с entry архив должен быть открыт в ArchiveDirectory в режиме Update
            _entry = entry;
            // path внутри архива
            AbstractPath = abstractPath;

            AbstractName = entry.Name;
            AbstractSize = entry.CompressedLength;
            DateOfLastAppeal = entry.LastWriteTime.DateTime.ToString(CultureInfo.InvariantCulture);
        }
开发者ID:Hakerok,项目名称:File_Manager,代码行数:11,代码来源:ArchiveFile.cs


示例20: TransformFile

        public void TransformFile(ZipArchiveEntry packageFile, string targetPath, IMSBuildNuGetProjectSystem msBuildNuGetProjectSystem)
        {
            // Get the xml fragment
            XElement xmlFragment = GetXml(packageFile, msBuildNuGetProjectSystem);

            XDocument transformDocument = XmlUtility.GetOrCreateDocument(xmlFragment.Name, targetPath, msBuildNuGetProjectSystem);

            // Do a merge
            transformDocument.Root.MergeWith(xmlFragment, _nodeActions);

            MSBuildNuGetProjectSystemUtility.AddFile(msBuildNuGetProjectSystem, targetPath, transformDocument.Save);
        }
开发者ID:pabomex,项目名称:NuGet.PackageManagement,代码行数:12,代码来源:XmlTransformer.cs



注:本文中的System.IO.Compression.ZipArchiveEntry类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Compression.ZipStorer类代码示例发布时间:2022-05-26
下一篇:
C# Compression.ZipArchive类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap