Exemplo n.º 1
0
        protected void AddEntry(Package package, string path, byte[] data)
        {
            string[]      array         = path.Split(new char[] { Path.DirectorySeparatorChar });
            PackageFolder packageFolder = (PackageFolder)package;

            for (int i = 0; i < array.Length - 1; ++i)
            {
                packageFolder = packageFolder.GetEntry <PackageFolder>(array[i]);
            }
            packageFolder.GetEntry <PackageFile>(array[array.Length - 1]).Data = data;
        }
Exemplo n.º 2
0
 private void WriteFolder(ZipOutputStream zipStream, string path, PackageFolder folder)
 {
     foreach (PackageEntry packageEntry in (IEnumerable <PackageEntry>)folder.GetEntries())
     {
         if (packageEntry is PackageFile)
         {
             zipStream.PutNextEntry(new ZipEntry(this.CombinePath(path, packageEntry.Name)));
             byte[] data = ((PackageFile)packageEntry).Data;
             ((Stream)zipStream).Write(data, 0, data.Length);
             zipStream.CloseEntry();
         }
         if (packageEntry is PackageFolder)
         {
             this.WriteFolder(zipStream, this.CombinePath(path, packageEntry.Name), (PackageFolder)packageEntry);
         }
     }
 }
Exemplo n.º 3
0
 private void Write(DirectoryInfo directory, PackageFolder folder)
 {
     foreach (PackageEntry entry in folder.GetEntries())
     {
         if (!this.FilterEntry(entry))
         {
             if (entry is PackageFolder)
             {
                 this.Write(directory.CreateSubdirectory(entry.Name), (PackageFolder)entry);
             }
             if (entry is PackageFile)
             {
                 File.WriteAllBytes(Path.Combine(directory.FullName, entry.Name), ((PackageFile)entry).Data);
             }
         }
     }
 }