資源簡介
WCF接收Client端數據,進行轉發其他客戶端,也可以直接進行一對一通信,親測可用。
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Configuration;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
namespace?Client
{
????public?class?AppConfig
????{
????????public?string?UserName?{?get;?set;?}
????????public?string?GetUserName()
????????{
????????????return?“游客“?+?DateTime.Now.ToString(“MMddhhmmssfff“);
????????}
????????public?string?GetUserAppName()
????????{
????????????System.xml.xmlDocument?xDoc?=?new?System.xml.xmlDocument();
????????????xDoc.Load(System.Windows.Forms.Application.ExecutablePath?+?“.config“);
????????????System.xml.xmlNode?xNode;
????????????System.xml.xmlElement?xElem1;
????????????xNode?=?xDoc.SelectSingleNode(“//appSettings“);
????????????xElem1?=?(System.xml.xmlElement)xNode.SelectSingleNode(“//add[@key=‘UserName‘]“);
????????????return?xElem1.GetAttribute(“value“);
????????}
????????public?void?SetUserName(string?name)
????????{
????????????System.xml.xmlDocument?xDoc?=?new?System.xml.xmlDocument();
????????????xDoc.Load(System.Windows.Forms.Application.ExecutablePath?+?“.config“);
????????????System.xml.xmlNode?xNode;
????????????System.xml.xmlElement?xElem1;
????????????xNode?=?xDoc.SelectSingleNode(“//appSettings“);
????????????xElem1?=?(System.xml.xmlElement)xNode.SelectSingleNode(“//add[@key=‘UserName‘]“);
????????????if?(xElem1?!=?null)?xElem1.SetAttribute(“value“?name);
????????????xDoc.Save(System.Windows.Forms.Application.ExecutablePath?+?“.config“);
????????}
????}
}
評論
共有 條評論