void Load(string filename) { using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read)) { if (!ReadFiles.IsHeaderValid(fs, "AUIF")) { //free up the file so it can be deleted fs.Close(); throw new Exception("Auto update state file ID is wrong."); } byte bType = (byte)fs.ReadByte(); while (!ReadFiles.ReachedEndByte(fs, bType, 0xFF)) { switch (bType) { case 0x01: // Date last checked for update LastCheckedForUpdate = ReadFiles.ReadDateTime(fs); break; case 0x02: // update step on UpdateStepOn = (UpdateStepOn)ReadFiles.ReadInt(fs); break; case 0x03: AutoUpdaterStatus = (AutoUpdaterStatus)ReadFiles.ReadInt(fs); break; case 0x04: // update succeeded UpdateVersion = ReadFiles.ReadString(fs); break; case 0x05: ChangesInLatestVersion = ReadFiles.ReadString(fs); break; case 0x06: ChangesIsRTF = ReadFiles.ReadBool(fs); break; case 0x07: // update failed ErrorTitle = ReadFiles.ReadString(fs); break; case 0x08: ErrorMessage = ReadFiles.ReadString(fs); break; default: ReadFiles.SkipField(fs, bType); break; } bType = (byte)fs.ReadByte(); } } }
private void Load(string filename) { using (FileStream fileStream = new FileStream(filename, FileMode.Open, FileAccess.Read)) { if (!ReadFiles.IsHeaderValid(fileStream, "AUIF")) { fileStream.Close(); throw new Exception("Auto update state file ID is wrong."); } byte b = (byte)fileStream.ReadByte(); while (!ReadFiles.ReachedEndByte(fileStream, b, byte.MaxValue)) { switch (b) { case 1: LastCheckedForUpdate = ReadFiles.ReadDateTime(fileStream); break; case 2: UpdateStepOn = (UpdateStepOn)ReadFiles.ReadInt(fileStream); break; case 3: AutoUpdaterStatus = (AutoUpdaterStatus)ReadFiles.ReadInt(fileStream); break; case 4: UpdateVersion = ReadFiles.ReadString(fileStream); break; case 5: ChangesInLatestVersion = ReadFiles.ReadString(fileStream); break; case 6: ChangesIsRTF = ReadFiles.ReadBool(fileStream); break; case 7: ErrorTitle = ReadFiles.ReadString(fileStream); break; case 8: ErrorMessage = ReadFiles.ReadString(fileStream); break; default: ReadFiles.SkipField(fileStream, b); break; } b = (byte)fileStream.ReadByte(); } } }
void Load(string filename) { #if !CLIENT // Disable filesystem redirection on x64 (mostly for Windows Services) if (Is32BitProcessOn64BitProcessor()) { EnableWow64FSRedirection(false); } try { #endif using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read)) { if (!ReadFiles.IsHeaderValid(fs, "AUIF")) { //free up the file so it can be deleted fs.Close(); throw new Exception("Auto update state file ID is wrong."); } byte bType = (byte)fs.ReadByte(); while (!ReadFiles.ReachedEndByte(fs, bType, 0xFF)) { switch (bType) { case 0x01: // Date last checked for update LastCheckedForUpdate = ReadFiles.ReadDateTime(fs); break; case 0x02: // update step on UpdateStepOn = (UpdateStepOn)ReadFiles.ReadInt(fs); break; case 0x03: AutoUpdaterStatus = (AutoUpdaterStatus)ReadFiles.ReadInt(fs); break; case 0x04: // update succeeded UpdateVersion = ReadFiles.ReadString(fs); break; case 0x05: ChangesInLatestVersion = ReadFiles.ReadString(fs); break; case 0x06: ChangesIsRTF = ReadFiles.ReadBool(fs); break; case 0x07: // update failed ErrorTitle = ReadFiles.ReadString(fs); break; case 0x08: ErrorMessage = ReadFiles.ReadString(fs); break; default: ReadFiles.SkipField(fs, bType); break; } bType = (byte)fs.ReadByte(); } } #if !CLIENT } finally { // Re-enable filesystem redirection on x64 if (Is32BitProcessOn64BitProcessor()) { EnableWow64FSRedirection(true); } } #endif }