public static DSE_File Load(string path) { //Init DSE_File dseFile = new DSE_File() { DSE_Entries = new List <DSE_Entry>() }; byte[] rawBytes = File.ReadAllBytes(path); //Header int count = BitConverter.ToInt32(rawBytes, 8); int offset = BitConverter.ToInt32(rawBytes, 12); //Entries for (int i = 0; i < count; i++) { dseFile.DSE_Entries.Add(new DSE_Entry() { I_00 = BitConverter.ToInt32(rawBytes, offset + 0), I_04 = BitConverter.ToInt32(rawBytes, offset + 4), I_08 = BitConverter.ToInt32(rawBytes, offset + 8), I_12 = BitConverter.ToInt32(rawBytes, offset + 12), }); offset += 16; } return(dseFile); }
public static void LoadXmlAndSave(string xmlPath) { string saveLocation = String.Format("{0}/{1}", Path.GetDirectoryName(xmlPath), Path.GetFileNameWithoutExtension(xmlPath)); YAXSerializer serializer = new YAXSerializer(typeof(DSE_File), YAXSerializationOptions.DontSerializeNullObjects); DSE_File dseFile = (DSE_File)serializer.DeserializeFromFile(xmlPath); byte[] bytes = dseFile.GetBytes(); File.WriteAllBytes(saveLocation, bytes); }