public static void ReadAllCfg(string path) { if (File.Exists(path)) { cfgDataDic = new Dictionary <string, byte[]>(); using (FileStream sr = File.OpenRead(path)) { byte[] allData = new byte[sr.Length]; sr.Read(allData, 0, allData.Length); //Console.WriteLine("解前 \n" + allData); //Console.WriteLine("解后 \n" + CompressHelper.Decompress(allData)); allData = CompressHelper.Decompress(allData); ByteArray ba = new ByteArray(allData); while (ba.CanRead()) { try { //表名 string tableName = ba.ReadString(); //长度 long length = ba.ReadInt64(); //数据 byte[] data = ba.ReadBytes((int)length); if (cfgDataDic.ContainsKey(tableName)) { Console.WriteLine("表名{0}有重复!!", tableName); } cfgDataDic[tableName] = data; } catch (Exception ex) { Console.WriteLine(ex.ToString()); break; } } } } }
public static void ReadAllCfg(System.Action cb) { string fileName = LocalizationMgr.Ins.currentLanguage; ResMgr.Ins.GetAsset <TextAsset>("ConfigData", fileName, (tx) => { byte[] content = tx.bytes; content = CompressHelper.Decompress(content); ByteArray ba = new ByteArray(content); while (ba.CanRead()) { try { //表名 string tableName = ba.ReadString(); //长度 long length = ba.ReadInt64(); //数据 byte[] data = ba.ReadBytes((int)length); if (cfgDataDic.ContainsKey(tableName)) { Debug.Log("表名 " + tableName + " 有重复!!"); } cfgDataDic[tableName] = data; } catch (Exception ex) { Debug.Log(ex.ToString()); break; } } if (cb != null) { cb(); } }); }