public bool CreateNewFile(SettingsContent.FileType fileType, string fileName) { bool retValue = false; try { string fileExtName = fileType == SettingsContent.FileType.PROJECT ? SettingsContent.projectFileExtName : SettingsContent.universalFileExtName; string fileFullPath = Path.GetFullPath(fileName + fileExtName); string tempFilePath = Path.GetFullPath(SettingsContent.tempFilePath + "\\" + FileEncryption.GUIDGenerate() + ".tmp"); if (File.Exists(fileFullPath)) { File.Delete(fileFullPath); } File.AppendAllText(tempFilePath, string.Empty); if (File.Exists(tempFilePath) && !File.Exists(fileFullPath)) { SetSettingsFilePath(tempFilePath); WriteValue("file_summary", "encrypt", "1"); WriteValue("file_summary", "filetype", ((int)fileType).ToString()); Dispose(); FileEncryption.DesEncryptFile(tempFilePath, fileFullPath, SettingsContent.encryptKey); retValue = true; } } catch (Exception) { }; return(retValue); }
public void SetSettingsFilePath(string path) { this.sPath = path; CheckFileEncrypt(); if (fileEncrypt) { originalPath = path; tempFileGUID = FileEncryption.GUIDGenerate() + ".tmp"; FileEncryption.DesDecryptFile(originalPath, SettingsContent.tempFilePath + "\\" + tempFileGUID, SettingsContent.encryptKey); this.sPath = SettingsContent.tempFilePath + "\\" + tempFileGUID; } }
public void Dispose() { if (fileEncrypt) { try { File.Delete(originalPath); } catch (Exception) { }; try { FileEncryption.DesEncryptFile(SettingsContent.tempFilePath + "\\" + tempFileGUID, originalPath, SettingsContent.encryptKey); } catch (Exception) { }; try { File.Delete(SettingsContent.tempFilePath + "\\" + tempFileGUID); } catch (Exception) { }; } fileEncrypt = false; this.sPath = null; }