本文整理汇总了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;
}
示例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;
}
示例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;
}