/// <summary> /// Extracts all files. /// </summary> /// <param name="deleteFiles">if set to <c>true</c> [delete files].</param> /// <returns> /// An <see cref="OperationResult" /> containing the results /// of the operation. /// </returns> /// <externalUnit/> /// <revision revisor="dev13" date="11/17/2009" version="1.1.3.5"> /// Added documentation header /// </revision> private OperationResult ExtractAllFiles(bool deleteFiles) { var result = new OperationResult(true); // Returned result string fileName = String.Empty; // Current file name // List of archive filenames, not including signature files. List <string> fileNames = new List <string>(); while (this.ExtractFile(ref fileName)) { if (fileName == "Manifest.xml") { // Recreate the manifest from the XML file. this.manifest = FileManifest.FromXmlFile( Path.Combine(this.dataPath, "Manifest.xml")); } else { fileNames.Add(fileName); } } if (this.manifest == null) { string error = String.Format( "Manifest missing for encrypted archive {0}", this.archiveName); // We should have a manifest result = new OperationResult(false, error); } // Delete signature files, plus optionally the data files. foreach (string name in fileNames) { string pathName = Path.Combine(this.dataPath, name); if (deleteFiles) { File.Delete(pathName); } // The .sig file has done its job, so delete it. File.Delete(pathName + ".sig"); } //File.Delete(Path.Combine(this.dataPath, "Manifest.xml")); File.Delete(Path.Combine(this.dataPath, "Manifest.xml.sig")); return(result); }
public void ManifestTest() { this.CleanTempPath(true); this.PopulateTempPath(); var manifest = new FileManifest(this.tempPath); manifest.AddFile("Ballots.xml"); manifest.AddFile("Cards.xml"); manifest.AddFile("Faces.xml"); manifest.ToXmlFile(Path.Combine(this.tempPath, "Manifest.xml")); manifest = FileManifest.FromXmlFile( Path.Combine(this.tempPath, "Manifest.xml")); string fileName = String.Empty; OperationResult result = manifest.IsValid(); Assert.IsTrue(result.Succeeded); }