/// <summary> /// Creates the encrypted archive. /// </summary> /// <param name="selectedFolder">The selected folder.</param> /// <param name="archiveName">Name of the archive.</param> /// <externalUnit/> /// <revision revisor="dev13" date="11/18/2009" version="1.1.3.6"> /// Added documentation header /// </revision> private void CreateEncryptedArchive( string selectedFolder, string archiveName) { try { string publicKey = string.Empty; string archiveFileName = string.IsNullOrEmpty(archiveName) ? "TestEncryptedArchive" : archiveName; string fullArchiveFilename = archiveFileName + ".zip"; using (var encryptedArchive = new EncryptedArchive( selectedFolder, fullArchiveFilename, new SequoiaCryptoProvider())) { encryptedArchive.OpenWrite(DateTime.Now, true); foreach ( string pathName in Directory.GetFiles(selectedFolder)) { string fileName = System.IO.Path.GetFileName(pathName); if (fileName == fullArchiveFilename) { continue; } // encryptedArchive.AddFile(fileName); byte[] fileData = File.ReadAllBytes(pathName); encryptedArchive.AddFile(fileData, fileName); } } var sequoiaProvider = new SequoiaCryptoProvider(); sequoiaProvider.CreateSignature( Path.Combine( selectedFolder, Path.ChangeExtension(fullArchiveFilename, "enc"))); } catch (Exception exception) { MessageBox.Show( string.Format( "Error creating encrypted archive: {0}", exception.Message), "Encrypted Archive Creation Failure", MessageBoxButton.OK, MessageBoxImage.Error); } }
/// <summary> /// Makes the encrypted archive. /// </summary> /// <externalUnit/> /// <revision revisor="dev13" date="11/18/2009" version="1.1.3.6"> /// Added documentation header /// </revision> private void MakeEncryptedArchive() { using (var sa = new EncryptedArchive( this.tempPath, "archive.zip", new SequoiaCryptoProvider(false))) { sa.OpenWrite(DateTime.Today, true); foreach (string pathName in Directory.GetFiles(this.tempPath)) { string fileName = Path.GetFileName(pathName); if (fileName == "archive.zip") { continue; } sa.AddFile(fileName); } } }