当前位置: 代码迷 >> Windows Mobile >> WM6.0记住小弟我C#程序
  详细解决方案

WM6.0记住小弟我C#程序

热度:420   发布时间:2016-04-25 07:43:47.0
WM6.0记住我C#程序
第一次打开程序输入用户名和密码,以后打开程序就自动登录(如电脑上网时网页账号自动登录)
求高手帮忙!


------解决方案--------------------
string pathExe = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); //exe的地址
string pathFile=pathExe+@"\fileName.txt"; //保存的地址


//读取
StreamReader objReader = new StreamReader(pathFile, Encoding.GetEncoding("UTF-8"));
string strContent = objReader.ReadToEnd(); //读出的字符串
objReader.Close();


//写入
string strWrite="abc"; //要写入的字符串
 byte[] bstr = Encoding.UTF8.GetBytes(strWrite);
FileStream fp = new FileStream(Path, FileMode.Create);
fp.Write(bstr, 0, bstr.Length);
fp.Close();
  相关解决方案