//Open Pre-RC2 client files public void OpenObsoleteClientFile(string fileName) { FileStream fs = null; try { fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); } catch (Exception ex) { if (fs != null) { fs.Close(); } throw new ArgumentException("The client data file (client.wyc) failed to open.\n\nFull details:\n\n" + ex.Message); } // Read back the file identification data, if any if (!ReadFiles.IsHeaderValid(fs, "IUCDFV2")) { //free up the file so it can be deleted fs.Close(); throw new ArgumentException("The client file does not have the correct identifier - this is usually caused by file corruption. \n\nA possible solution is to replace the following file by reinstalling:\n\n" + fileName); } byte bType = (byte)fs.ReadByte(); while (!ReadFiles.ReachedEndByte(fs, bType, 0xFF)) { switch (bType) { case 0x01: // Read Company Name CompanyName = ReadFiles.ReadDeprecatedString(fs); break; case 0x02: // Product Name ProductName = ReadFiles.ReadDeprecatedString(fs); break; case 0x03: // Read Installed Version InstalledVersion = ReadFiles.ReadDeprecatedString(fs); break; case 0x04: // Add server file site AddUniqueString(ReadFiles.ReadDeprecatedString(fs), ServerFileSites); break; case 0x09: // Add client server file site AddUniqueString(ReadFiles.ReadDeprecatedString(fs), ClientServerSites); break; case 0x11: // Header image alignment try { HeaderImageAlign = (ImageAlign)Enum.Parse(typeof(ImageAlign), ReadFiles.ReadDeprecatedString(fs)); } catch { } break; case 0x12: // Header text indent HeaderTextIndent = ReadFiles.ReadInt(fs); break; case 0x13: // Header text color HeaderTextColorName = ReadFiles.ReadDeprecatedString(fs); break; case 0x06: // top Image TopImage = ReadFiles.ReadImage(fs); break; case 0x07: // side Image SideImage = ReadFiles.ReadImage(fs); break; default: ReadFiles.SkipField(fs, bType); break; } bType = (byte)fs.ReadByte(); } fs.Close(); }
public void OpenObsoleteClientFile(string fileName) { FileStream fileStream = null; try { fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); } catch (Exception ex) { fileStream?.Close(); throw new ArgumentException("The client data file (client.wyc) failed to open.\n\nFull details:\n\n" + ex.Message); } if (!ReadFiles.IsHeaderValid(fileStream, "IUCDFV2")) { fileStream.Close(); throw new ArgumentException("The client file does not have the correct identifier - this is usually caused by file corruption. \n\nA possible solution is to replace the following file by reinstalling:\n\n" + fileName); } byte b = (byte)fileStream.ReadByte(); while (!ReadFiles.ReachedEndByte(fileStream, b, byte.MaxValue)) { switch (b) { case 1: CompanyName = ReadFiles.ReadDeprecatedString(fileStream); break; case 2: ProductName = ReadFiles.ReadDeprecatedString(fileStream); break; case 3: InstalledVersion = ReadFiles.ReadDeprecatedString(fileStream); break; case 4: AddUniqueString(ReadFiles.ReadDeprecatedString(fileStream), ServerFileSites); break; case 9: AddUniqueString(ReadFiles.ReadDeprecatedString(fileStream), ClientServerSites); break; case 17: try { HeaderImageAlign = (ImageAlign)Enum.Parse(typeof(ImageAlign), ReadFiles.ReadDeprecatedString(fileStream)); } catch { } break; case 18: HeaderTextIndent = ReadFiles.ReadInt(fileStream); break; case 19: HeaderTextColorName = ReadFiles.ReadDeprecatedString(fileStream); break; case 6: TopImage = ReadFiles.ReadImage(fileStream); break; case 7: SideImage = ReadFiles.ReadImage(fileStream); break; default: ReadFiles.SkipField(fileStream, b); break; } b = (byte)fileStream.ReadByte(); } fileStream.Close(); }