/// <summary> /// 保存广播信息 应该是还未来得及显示的 /// </summary> public void M_saveRadioMsg(int radioType) { if (!radioInfoDic.ContainsKey(radioType)) { return; } string saveContent = string.Empty; RadioInfo radioInfo = radioInfoDic [radioType]; Queue <string> msgCache = radioInfo.msgCache; while (msgCache.Count > 0) { saveContent += ("#" + msgCache.Dequeue()); } if (saveContent == string.Empty) { return; } string path = ConfigGlobal.CONFIG_FOLDER + "/" + ConfigGlobal.CONFIG_RADIO_MSG; string holePath = PathKit.GetOSDataPath(path) + SUFFIX; FileStream fs = new FileStream(holePath, FileMode.OpenOrCreate, FileAccess.Write); StreamWriter sw = new StreamWriter(fs); sw.Flush(); sw.BaseStream.Seek(0, SeekOrigin.Begin); sw.Write(saveContent); sw.Close(); }
/// <summary> /// 创建文件 /// </summary> /// <param name="path">Path.</param> private void M_createFile(string path) { string holePath = PathKit.GetOSDataPath(path) + SUFFIX; FileStream fs = new FileStream(holePath, FileMode.OpenOrCreate, FileAccess.Write); StreamWriter sw = new StreamWriter(fs); sw.Flush(); sw.BaseStream.Seek(0, SeekOrigin.Begin); sw.Close(); }
/// <summary> /// 读取缓存广播 /// </summary> private void M_readCacheMsg() { string path = ConfigGlobal.CONFIG_FOLDER + "/" + ConfigGlobal.CONFIG_RADIO_MSG; string newPath = PathKit.GetOSDataPath(path) + SUFFIX; if (!File.Exists(newPath)) { M_createFile(path); return; } else { using (StreamReader sr = new StreamReader(newPath, Encoding.UTF8)) { string str = sr.ReadLine(); if (str != null) { string[] strs = str.Split(new char[] { '#' }, System.StringSplitOptions.RemoveEmptyEntries); M_addRadioMsg(RADIO_MAIN_TYPE, strs); // 暂时只支持保存主界面广播 } } } }
//获得配置文件完整路径 private string getConfigHolePath(string path) { return(PathKit.GetOSDataPath(path) + PathKit.SUFFIX); }
//获得配置目录文件夹路径 private string getConfigFolder(string path) { return(PathKit.GetOSDataPath(path)); }