private static bool WriteSessionArchive(string sFilename, Session[] arrSessions, string sPassword, bool bDisplayErrorMessages)
        {
            if ((null == arrSessions || (arrSessions.Length < 1)))
            {
                if (bDisplayErrorMessages)
                {
                    FiddlerApplication.Log.LogString("WriteSessionArchive - No Input. No sessions were provided to save to the archive.");
                }
                return(false);
            }

            try
            {
                if (File.Exists(sFilename))
                {
                    File.Delete(sFilename);
                }

                DiskFile   odfZip = new DiskFile(sFilename);
                ZipArchive oZip   = new ZipArchive(odfZip);
                oZip.TempFolder = new MemoryFolder();

                oZip.BeginUpdate();
                ZippedFolder oZipRawFolder = (ZippedFolder)oZip.CreateFolder("raw");

                #region PasswordProtectIfNeeded
                if (!String.IsNullOrEmpty(sPassword))
                {
                    if (CONFIG.bUseAESForSAZ)
                    {
                        oZip.DefaultEncryptionMethod = EncryptionMethod.WinZipAes;  // Use 256bit AES
                    }
                    oZip.DefaultEncryptionPassword = sPassword;
                }
                #endregion PasswordProtectIfNeeded

                oZip.Comment = Fiddler.CONFIG.FiddlerVersionInfo + " " + GetZipLibraryInfo() + " Session Archive. See http://www.fiddler2.com";

                #region ProcessEachSession
                int iFileNumber = 1;
                foreach (Session oSession in arrSessions)
                {
                    WriteSessionToSAZ(oSession, odfZip, iFileNumber, null, bDisplayErrorMessages);
                    iFileNumber++;
                }
                #endregion ProcessEachSession

                oZip.EndUpdate();
                return(true);
            }
            catch (Exception eX)
            {
                // TODO: Should close any open handles here.
                if (bDisplayErrorMessages)
                {
                    FiddlerApplication.Log.LogString("Failed to save Session Archive.\n\n" + eX.Message);
                }
                return(false);
            }
        }
Exemplo n.º 2
0
 public void Stop()
 {
     timer.Stop();
     lastSnapShot = null;
     Directory    = null;
 }
Exemplo n.º 3
0
 public SnapEventArgs(ZippedFolder directory)
 {
     Directory = directory;
 }
        /// <summary>
        /// Returns a boolean indicating if the specified folder exists in the library.
        /// </summary>
        public bool FolderExists(string path)
        {
            ZippedFolder folder = (archive.GetFolder(path) as ZippedFolder);

            return(folder.Exists);
        }