资源简介
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“);
}
}
}
评论
共有 条评论