예제 #1
0
 private static void serializeLibsToFile(ref DJTUBinary libs, ref FileStream file)
 {
     try {
         BinaryFormatter bf = new BinaryFormatter();
         bf.Serialize(file, libs);
     } catch {
         throw new SerializeException("存档初始化写入失败,建议重启程序");
     }
 }
예제 #2
0
        /* ----- init ----- */
        public static DJTUBinary initFromLocal()
        {
            DJTUBinary libs;
            FileStream file;

            try {
                file = OpenLocalFile();
                libs = deserialize(ref file);
                file.Close();
                return(libs);
            } catch (OpenFileException) {
                file = createFile();
                libs = new DJTUBinary();
                serializeLibsToFile(ref libs, ref file);
                file.Close();
                return(libs);
            } catch (DeserializeException e) { exitProgram(e.Message); }
            catch (CreateFileException e)    { exitProgram(e.Message); }
            catch (SerializeException e)    { exitProgram(e.Message); }
            return(null);
        }