public static bool WriteConfigBIN(AppConfigClass appConfig, string fileName) { bool flag; try { using (FileStream stream = File.Create(fileName)) { binWriter = new BinaryWriter(stream); binWriter.Write(0x31024071); binWriter.Write(appConfig.EnableAppDebug); binWriter.Write(appConfig.DeviceStorageLocation); binWriter.Write(appConfig.PITFileBufferSize); binWriter.Write(-1735290877); binWriter.Close(); } flag = true; } catch (Exception exception1) { ProjectData.SetProjectError(exception1); Exception exception = exception1; Interaction.MsgBox("Error writing App. Config file!", MsgBoxStyle.Critical, null); flag = false; ProjectData.ClearProjectError(); } return(flag); }
public static bool ReadConfigBIN(string fileName, ref AppConfigClass appConfig) { bool flag; try { string str; short num; int num2; using (FileStream stream = File.OpenRead(fileName)) { binReader = new BinaryReader(stream); if (binReader.ReadInt32() != 0x31024071) { Interaction.MsgBox("App. Config file contains an invalid header!", MsgBoxStyle.Critical, null); return(false); } num = binReader.ReadInt16(); str = binReader.ReadString(); num2 = binReader.ReadInt32(); binReader.BaseStream.Position = binReader.BaseStream.Length - 4L; if (binReader.ReadInt32() != -1735290877) { Interaction.MsgBox("App. Config file contains an invalid signature!", MsgBoxStyle.Critical, null); return(false); } binReader.Close(); } appConfig = new AppConfigClass(num, str, num2); flag = true; } catch (Exception exception1) { ProjectData.SetProjectError(exception1); Exception exception = exception1; Interaction.MsgBox("Error reading App. Config file!", MsgBoxStyle.Critical, null); flag = false; ProjectData.ClearProjectError(); } return(flag); }