当前位置: 首页>>代码示例>>C#>>正文


C# ZipArchive.AddEntry方法代码示例

本文整理汇总了C#中ZipArchive.AddEntry方法的典型用法代码示例。如果您正苦于以下问题:C# ZipArchive.AddEntry方法的具体用法?C# ZipArchive.AddEntry怎么用?C# ZipArchive.AddEntry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ZipArchive的用法示例。


在下文中一共展示了ZipArchive.AddEntry方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteFilesRecursiveToZip

        private static void WriteFilesRecursiveToZip(ZipArchive archive, IStorage storage, string basePath)
        {
            string searchPattern = basePath;
            string[] fileNames = storage.GetFileNames(searchPattern);

            foreach (string fileName in fileNames)
            {
                Stream fileStream = storage.OpenFile(basePath + "/" + fileName, StorageFileMode.Open,
                                                     StorageFileAccess.Read);
                archive.AddEntry(fileName, fileStream);
            }

            string[] directrryNames = storage.GetDirectoryNames(searchPattern);
            foreach (string directoryName in directrryNames)
            {
                WriteFilesRecursiveToZip(archive, storage, basePath + "/" + directoryName);
            }
        }
开发者ID:kernelhunter92,项目名称:CatrobatForWindows,代码行数:18,代码来源:CatrobatZip.cs

示例2: CreateZipEntry

        /// <summary>
        /// Creates a ZipEntry of the passed node and its childs to the passed zip file.
        /// </summary>
        /// <param name="zip">The zip file to add the new zip entry to.</param>
        /// <param name="node">The node to create a zip entry for.</param>
        /// <param name="processedNodeCount">Count of the processed nodes (for recursive calls only).</param>
        /// <returns>Count of the processed nodes.</returns>
        private static int CreateZipEntry(ZipArchive zip, ModNode node, int processedNodeCount = 0)
        {
            string absPath = KSPPathHelper.GetAbsolutePath(node.Destination);
            string gameDataPath = KSPPathHelper.GetPath(KSPPaths.GameData);
            string path = absPath.Replace(gameDataPath + Path.DirectorySeparatorChar, string.Empty);
            if (node.IsFile && node.IsInstalled)
                zip.AddEntry(path, absPath);

            foreach (ModNode child in node.Nodes)
                processedNodeCount = CreateZipEntry(zip, child, processedNodeCount);

            return processedNodeCount;
        }
开发者ID:timmersuk,项目名称:KSP-Mod-Admin-aOS,代码行数:20,代码来源:ModZipCreator.cs

示例3: AddSubDirs

        /// <summary>
        /// Adds the sub directory to the Archive.
        /// </summary>
        /// <param name="parentDir">Parent directory to scan for sub directories and files.</param>
        /// <param name="archive">The Archive to add the directories and files to.</param>
        private static void AddSubDirs(string parentDir, ZipArchive archive)
        {
            foreach (string subDir in Directory.GetDirectories(parentDir))
            {
                foreach (string file in Directory.GetFiles(subDir))
                {
                    string directoryName = Path.GetDirectoryName(file);
                    if (directoryName != null)
                    {
                        string temp = Path.Combine(directoryName.Replace(KSPPathHelper.GetPath(KSPPaths.KSPRoot) + Path.DirectorySeparatorChar, string.Empty), Path.GetFileName(file));
                        archive.AddEntry(temp, file);
                    }
                }

                AddSubDirs(subDir, archive);
            }
        }
开发者ID:timmersuk,项目名称:KSP-Mod-Admin-aOS,代码行数:22,代码来源:UcBackupViewController.cs


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