public void LockFile(string filepath, string password) { Validate PasswordValidate = new PasswordValidation(password); PasswordValidate.ValidateData(); Validate FileExistsValidate = new SBNExists(Path.GetFileName(filepath)); FileExistsValidate.ValidateData(); CreateSTF GenerateSTF = new CreateSTF(filepath, HEADERCODE, ENDMARKER); GenerateSTF.GenerateSTF(); IEncrypt Encrypter = new InstantiateElement().CreateNewInstance(ConfigurationSettings.AppSettings["Encrypter_Assembly"], Path.GetFileName(filepath), password) as IEncrypt; Encrypter.EncryptFile(); string STFFilename = ConfigurationSettings.AppSettings["AllEntityLocation"] + Path.GetFileName(filepath) + "." + ConfigurationSettings.AppSettings["SecureBinTemporaryExtension"]; if (File.Exists(STFFilename)) { File.Delete(STFFilename); } if (bool.Parse(ConfigurationSettings.AppSettings["DeleteSource"]) == true) { if (System.IO.File.Exists(filepath)) { System.IO.File.Delete(filepath); } } }
public void LockFolder(string absoluteFolderPath, string Password) { #region LockFolder implementation LockParameters.FlushAll(); Validate PasswordValidate = new PasswordValidation(Password); PasswordValidate.ValidateData(); string DirectoryName = GetLeafDirectoryName(absoluteFolderPath); Validate FolderExistsValidate = new SBNExists(Path.GetFileName(DirectoryName)); FolderExistsValidate.ValidateData(); CreateFolderHierarchy createFolderHierarchy = new CreateFolderHierarchy(absoluteFolderPath); Root fileSystemHierarchyManager = createFolderHierarchy.FolderHierarchy; string DirName = Path.GetFileName(absoluteFolderPath); ConfigurationManager SaveConfiguration = new ConfigurationManager(); SaveConfiguration.WriteFileHierarchyXml("HierarchySize.xml", fileSystemHierarchyManager); System.IO.FileInfo finfo = new FileInfo("HierarchySize.xml"); long SizeOfXmlBlock = finfo.Length; try { CreateSTF STF = new CreateSTF(SECURITYCODE, SizeOfXmlBlock, DirName, ENDMARKER, fileSystemHierarchyManager); } catch (Exception ex) { throw (new ApplicationException(ConfigurationSettings.AppSettings["SecureBinTemporaryExtension"] + " File Creation Failed")); } IEncrypt Encrypter = new InstantiateElement().CreateNewInstance(ConfigurationSettings.AppSettings["Encrypter_Assembly"], DirName, Password) as IEncrypt; Encrypter.EncryptFile(); System.IO.File.Delete(ConfigurationSettings.AppSettings["AllEntityLocation"] + DirName + "." + ConfigurationSettings.AppSettings["SecureBinTemporaryExtension"]); if (bool.Parse(ConfigurationSettings.AppSettings["DeleteSource"]) == true) { if (System.IO.Directory.Exists(absoluteFolderPath)) { System.IO.Directory.Delete(absoluteFolderPath, true); } } if (System.IO.File.Exists("HierarchySize.xml")) { System.IO.File.Delete("HierarchySize.xml"); } #endregion }