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


C# ZipArchive.AddEntry方法代码示例

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


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

示例1: GetLegacyFolderPackage

        public static FileInfo GetLegacyFolderPackage()
        {
            var file = Path.GetTempFileName() + ".nupkg";
            var result = new FileInfo(file);

            using (var zip = new ZipArchive(File.Create(result.FullName), ZipArchiveMode.Create))
            {
                zip.AddEntry("lib/a.dll", new byte[] { 0 });
                zip.AddEntry("lib/35/b.dll", new byte[] { 0 });
                zip.AddEntry("lib/40/test40.dll", new byte[] { 0 });
                zip.AddEntry("lib/40/x86/testx86.dll", new byte[] { 0 });
                zip.AddEntry("lib/45/a.dll", new byte[] { 0 });

                zip.AddEntry("packageA.nuspec", @"<?xml version=""1.0"" encoding=""utf-8""?>
                            <package xmlns=""http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"">
                              <metadata>
                                <id>packageA</id>
                                <version>2.0.3</version>
                                <authors>Author1, author2</authors>
                                <description>Sample description</description>
                                <language>en-US</language>
                                <projectUrl>http://www.nuget.org/</projectUrl>
                                <licenseUrl>http://www.nuget.org/license</licenseUrl>
                              </metadata>
                            </package>", Encoding.UTF8);
            }

            return result;
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:29,代码来源:TestPackages.cs

示例2: GetNearestReferenceFilteringPackage

        public static FileInfo GetNearestReferenceFilteringPackage()
        {
            var file = Path.GetTempFileName() + ".nupkg";
            var result = new FileInfo(file);

            using (var zip = new ZipArchive(File.Create(result.FullName), ZipArchiveMode.Create))
            {
                zip.AddEntry("lib/net40/one.dll", new byte[] { 0 });
                zip.AddEntry("lib/net40/three.dll", new byte[] { 0 });
                zip.AddEntry("lib/net40/two.dll", new byte[] { 0 });

                zip.AddEntry("lib/sl40/a.dll", new byte[] { 0 });
                zip.AddEntry("lib/sl40/b.dll", new byte[] { 0 });

                zip.AddEntry("packageA.nuspec", @"<?xml version=""1.0"" encoding=""utf-8""?>
                                      <package xmlns=""http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd"">
                                         <metadata>
                                        <id>RefPackage</id>
                                            <version>1.0.0</version>
                                            <title />
                                           <references>
                                               <group targetFramework=""net"">
                                                   <reference file=""one.dll"" />
                                                   <reference file=""three.dll"" />
                                               </group>    
                                                <group targetFramework=""silverlight40"">
                                                    <reference file=""a.dll"" />
                                               </group>
                                        </references>
                                    </metadata>
                                    <files>
                                        <file src=""lib\net40\one.dll"" target=""lib\net40\one.dll"" />
                                        <file src=""lib\net40\three.dll"" target=""lib\net40\three.dll"" />
                                        <file src=""lib\net40\two.dll"" target=""lib\net40\two.dll"" />

                                        <file src=""lib\sl40\a.dll"" target=""lib\sl40\a.dll"" />
                                        <file src=""lib\sl40\b.dll"" target=""lib\sl40\b.dll"" />
                                   </files>
                                </package>", Encoding.UTF8);
            }

            return result;
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:43,代码来源:TestPackages.cs

示例3: GetLegacyTestPackage

        public static FileInfo GetLegacyTestPackage()
        {
            var file = Path.GetTempFileName() + ".nupkg";
            var result = new FileInfo(file);

            using (var zip = new ZipArchive(File.Create(result.FullName), ZipArchiveMode.Create))
            {
                zip.AddEntry("lib/test.dll", new byte[] { 0 });
                zip.AddEntry("lib/net40/test40.dll", new byte[] { 0 });
                zip.AddEntry("lib/net40/test40b.dll", new byte[] { 0 });
                zip.AddEntry("lib/net45/test45.dll", new byte[] { 0 });

                zip.AddEntry("packageA.nuspec", @"<?xml version=""1.0"" encoding=""utf-8""?>
                            <package xmlns=""http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"">
                              <metadata>
                                <id>packageA</id>
                                <version>2.0.3</version>
                                <authors>Author1, author2</authors>
                                <description>Sample description</description>
                                <language>en-US</language>
                                <projectUrl>http://www.nuget.org/</projectUrl>
                                <licenseUrl>http://www.nuget.org/license</licenseUrl>
                                <dependencies> 
                                   <group>
                                      <dependency id=""RouteMagic"" version=""1.1.0"" />
                                   </group>
                                   <group targetFramework=""net40"">
                                      <dependency id=""jQuery"" />
                                      <dependency id=""WebActivator"" />
                                   </group>
                                   <group targetFramework=""sl30"">
                                   </group>
                                </dependencies>
                              </metadata>
                            </package>", Encoding.UTF8);
            }

            return result;
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:39,代码来源:TestPackages.cs


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