标签:sre hide rtc reac star 写文件 none builder get
//3 列排序 Type t = data.ElementType; //var pcs = Activator.CreateInstance(t, new object[] { // "addTime", // Common.ListSortDirection.Ascending //}); Type type = typeof(PropertySortCondition<>); type = type.MakeGenericType(t); var pcs = Activator.CreateInstance(type, new object[] { "addTime", Common.ListSortDirection.Ascending });
#region 写文件(.txt-添加) /// <summary> /// 写文件 /// </summary> /// <param name="FileName">文件路径,相对路径,不需要写扩展名</param> /// <param name="Strings">文件内容</param> private void WriteFile(string FileName, string Strings) { string Path = System.Web.HttpContext.Current.Server.MapPath("~/" + FileName + ".txt"); if (!System.IO.File.Exists(Path)) { System.IO.FileStream f = System.IO.File.Create(Path); f.Close(); f.Dispose(); } System.IO.StreamWriter f2 = new System.IO.StreamWriter(Path, true, System.Text.Encoding.UTF8); f2.WriteLine(Strings); f2.Close(); f2.Dispose(); } #endregion
System.Threading.Interlocked.CompareExchange(ref "参数1","参数3","参数2");
参数1与参数2对比,一样就把参数3复制给参数1.不一样就把参数2赋值给参数1.这个方法返回的是原始的参数1,即返回值在此方法没有赋值前已经确认。
//创建xml文件 string mPath = Application.StartupPath + "/record.xml";//创建位置 if (!File.Exists(mPath)) { CreateXMLDoc(); mXmlDoc.Load(mPath); } //添加节点 public void CreateXMLDoc() { if (!File.Exists(mPath)) { XmlDocument xmldoc = new XmlDocument(); //加入XML的声明段落 xmldoc.AppendChild(xmldoc.CreateXmlDeclaration("1.0", "UTF-8", null)); XmlElement rMainNode = xmldoc.CreateElement("", "settings", ""); rMainNode.IsEmpty = false; xmldoc.AppendChild(rMainNode); XmlElement rIp = xmldoc.CreateElement("", "ips", ""); rIp.IsEmpty = false; rMainNode.AppendChild(rIp); XmlElement rPort = xmldoc.CreateElement("", "ports", ""); rPort.IsEmpty = false; rMainNode.AppendChild(rPort); XmlElement rName = xmldoc.CreateElement("", "names", ""); rName.IsEmpty = false; rMainNode.AppendChild(rName); XmlElement rPreviousRecord = xmldoc.CreateElement("", "previousreocrd", ""); rPreviousRecord.IsEmpty = false; rMainNode.AppendChild(rPreviousRecord); xmldoc.Save(mPath); } } /////删除节点 XmlNode rMainNode = mXmlDoc.SelectSingleNode("settings"); XmlNode rNode = rMainNode.SelectSingleNode("names"); XmlNodeList rList = rNode.ChildNodes; List<string> list = new List<string>(); foreach (XmlNode r in rList) { XmlElement rElem = (XmlElement)r; list.Add(rElem.GetAttribute("value").ToString().Split(‘,‘)[0]); if (rElem.GetAttribute("value").ToString().Split(‘,‘)[0] == tb_name.Text) { rNode.RemoveChild(rElem); } }
#region 读Ini文件 /// <summary> /// /// </summary> /// <param name="Section">节名</param> /// <param name="Key">键名</param> /// <param name="NoText">读取失败返回值</param> /// <param name="iniFilePath">路径</param> /// <returns>读取值</returns> public static string ReadIniData(string Section, string Key, string NoText, string iniFilePath) { if (File.Exists(iniFilePath)) { StringBuilder temp = new StringBuilder(1024); GetPrivateProfileString(Section, Key, NoText, temp, 1024, iniFilePath); return temp.ToString(); } else { return String.Empty; } } #endregion #region 写Ini文件 /// <summary> /// /// </summary> /// <param name="Section">节名</param> /// <param name="Key">键名</param> /// <param name="Value">值</param> /// <param name="iniFilePath">路径</param> /// <returns></returns> public static bool WriteIniData(string Section, string Key, string Value, string iniFilePath) { if (File.Exists(iniFilePath)) { long OpStation = WritePrivateProfileString(Section, Key, Value, iniFilePath); if (OpStation == 0) { return false; } else { return true; } } else { return false; } } #endregion
标签:sre hide rtc reac star 写文件 none builder get
原文地址:https://www.cnblogs.com/yanbigfeg/p/9129381.html