标签:des android style blog http color os io
一、Application.PresistentDataPath
注意最后面是没有/的
public static string PresistentDataPathForEditor = "C:/Users/Administrator/AppData/LocalLow/DefaultCompany/工程名"; public static string PresistentDataPathForAndroid = "/mnt/sdcard/Android/data/包名/files";
二、序列化与反序列化
[Serializable] public class CategoryBean { public string Name; static string FileName { get { return Application.persistentDataPath + "/category.dat"; } } public static void Load() { Global.Category = new CategoryBean(); if (File.Exists(FileName)) { try { using (FileStream fs = new FileStream(FileName, FileMode.Open, FileAccess.Read)) { BinaryFormatter b = new BinaryFormatter(); Global.Category = (CategoryBean)b.Deserialize(fs); } } catch (Exception ex) { Debuger.Log("Globals.load occurs an error:" + ex); } } else{ Debuger.Log("Local file is null"); } } public static void Save() { if (Global.Category == null) return; try { using (FileStream fs = new FileStream(FileName, FileMode.Create, FileAccess.Write)) { BinaryFormatter b = new BinaryFormatter(); b.Serialize(fs, Global.Category); } } catch (Exception ex) { Debuger.Log("Globals.Save occurs an error:" + ex); } } }
标签:des android style blog http color os io
原文地址:http://www.cnblogs.com/chongxin/p/3927152.html