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 SettingsContent.FileType GetFileType() { SettingsContent.FileType retValue = SettingsContent.FileType.UNKNOW; try { string dataValue = ReadValue("file_summary", "filetype"); if (dataValue == string.Empty || Convert.ToInt32(dataValue) > (int)SettingsContent.FileType.UNKNOW) { return(retValue); } retValue = (SettingsContent.FileType)Convert.ToInt32(dataValue); return(retValue); } catch (Exception) { }; return(retValue); }