Ejemplo n.º 1
0
        public static Stream CreateBlubbZip(string Password, string[] FileNames, Stream[] Entrys)
        {
            Stream SaveStream = new MemoryStream();

            using (BlubbZipOutputStream outputStream = new BlubbZipOutputStream(SaveStream)) {
                try {
                    outputStream.Password = Password;
                    outputStream.SetLevel(9);

                    for (int i = 0; i < Entrys.Length; i++)
                    {
                        ZipStream("", FileNames[i], Entrys[i], outputStream);
                    }
                } catch (Exception e) {
                    System.Diagnostics.Debug.WriteLine(e);
                } finally {
                    if (outputStream != null)
                    {
                        outputStream.Finish();                         // don't close, will close also underlying Stream!
                    }
                }
            }

            return(SaveStream);
        }
Ejemplo n.º 2
0
        public static MemoryStream CreateBlubbZip(string blubbzipPassword, string[] contentFilenames, Stream[] contentData)
        {
            MemoryStream saveStream = new MemoryStream();

            using (MemoryStream tempStream = new MemoryStream()) {
                using (BlubbZipOutputStream outputStream = new BlubbZipOutputStream(tempStream)) {
                    try {
                        outputStream.Password = blubbzipPassword;
                        outputStream.SetLevel(9);

                        for (int i = 0; i < contentData.Length; i++)
                        {
                            ZipStream("", contentFilenames[i], contentData[i], outputStream);
                        }
                    } catch (Exception e) {
                        System.Diagnostics.Debug.WriteLine(e);
                    } finally {
                        if (outputStream != null)
                        {
                            outputStream.Finish();                             // don't close, will close also underlying Stream!
                        }
                    }

                    tempStream.WriteTo(saveStream);
                }
            }

            return(saveStream);
        }