public void WriteTrees() { try { Stream file = ItemStorage.__FILE_GETSTREAM(filetrees); BinaryFormatter binFormat = new BinaryFormatter(); binFormat.Serialize(file, Trees); } catch { throw new CannotLoadExecutionContentException(); } }
void ReadTrees() { try { if (Trees != null) { Trees.Clear(); } Trees = new List <Vector2L>(); if (!File.Exists(filetrees)) { return; } Stream file = ItemStorage.__FILE_GETSTREAM(filetrees); BinaryFormatter binFormat = new BinaryFormatter(); Trees = (List <Vector2L>)binFormat.Deserialize(file); } catch { throw new CannotLoadExecutionContentException(); } }
/// <summary> /// 加载文件到内存并返回操作流,如果文件已经加载,将从内存中获取该文件操作流 /// </summary> /// <param name="fullloc">文件地址</param> /// <returns></returns> public static FileStream LoadFile(string fullloc) { return(ItemStorage.__FILE_GETSTREAM(fullloc)); }