System.IO.Compression.ZipArchive.AddEntry C# (CSharp) Метод

AddEntry() приватный Метод

private AddEntry ( ZipArchiveEntry entry ) : void
entry ZipArchiveEntry
Результат void
        private void AddEntry(ZipArchiveEntry entry)
        {
            _entries.Add(entry);

            string entryName = entry.FullName;
            if (!_entriesDictionary.ContainsKey(entryName))
            {
                _entriesDictionary.Add(entryName, entry);
            }
        }

Usage Example

Пример #1
0
        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;
        }
All Usage Examples Of System.IO.Compression.ZipArchive::AddEntry