public void UnlockFolder(string Filename, string NewRoot, string Password) { #region Unlock Folder Implementation Validate PasswordValidate = new PasswordValidation(Password); PasswordValidate.ValidateData(); string SBNFilename = GetSBNName(Filename); string STFFilename = GetSTFName(Filename); IDecrypt Decrypter = new InstantiateElement().CreateNewInstance(ConfigurationSettings.AppSettings["Decrypter_Assembly"], Path.GetFileName(SBNFilename), Password) as IDecrypt; try { Decrypter.DecryptFile(); } catch (Exception DecryptException) { throw (new ApplicationException("Incorrect password")); } ExtractSTF ExtractSTFFile = new ExtractSTF(STFFilename); UnlockParameters STFContents = ExtractSTFFile.ExtractSTFContents(); VerifySTFIntegrity CheckIntegrity = new VerifySTFIntegrity(); if (!CheckIntegrity.Verify(STFContents.FooterCode)) { throw (new ApplicationException("Incorrect password")); } DirectoryStructure CreateNewDirStructure = new DirectoryStructure(NewRoot, STFContents.XmlHeirarchy); CreateNewDirStructure.CreateDirectoryStructure(); RestoreFiles RestoreFilesFromSTF = new RestoreFiles(STFContents.XmlHeirarchy, STFContents.FileAttributes, NewRoot, STFFilename); RestoreFilesFromSTF.ExecuteRestore(); if (System.IO.File.Exists(STFFilename)) { System.IO.File.Delete(STFFilename); } if (System.IO.File.Exists(ConfigurationSettings.AppSettings["AllEntityLocation"] + SBNFilename)) { System.IO.File.Delete(ConfigurationSettings.AppSettings["AllEntityLocation"] + SBNFilename); } if (System.IO.File.Exists("GeneratedHierarchy.xml")) { System.IO.File.Delete("GeneratedHierarchy.xml"); } #endregion }
public RestoreFileInformation GetFile(string sourcePath) { return(RestoreFiles.FirstOrDefault(x => x.SourcePath == sourcePath)); }