Click here to Skip to main content
15,886,626 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI,

I am working on windows Azure. And I need the code to Zip the folder(Containers) in Azure itself . Yet now i did not get any code from Internet.

Thanks
Sarath
Posted
Updated 25-Mar-13 21:33pm
v3

1 solution

U need to download DotNetZip.Dll file and use..

Below is some very stripped down code showing the process:

C#
using (ZipFile zipFile = new ZipFile())
{
    foreach (var uri in uriCollection)
    {
        var blob = new CloudBlob(uri);

        byte[] fileBytes = blob.DownloadByteArray();

        using (var fileStream = new MemoryStream(fileBytes))
        {
            fileStream.Seek(0, SeekOrigin.Begin);
            
            //U May avoid encryption 
            byte[] bytes = CryptoHelp.EncryptAsBytes(fileStream, "password", null);

            zipFile.AddEntry("entry name", bytes);
        }
    }

    using (var zipStream = new MemoryStream())
    {
        zipFile.Save(zipStream);
        zipStream.Seek(0, SeekOrigin.Begin);

        var blobRef = ContainerDirectory.GetBlobReference("output uri");
        blobRef.UploadFromStream(zipStream);
    }

}
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900