做好一个数据库系统一开始需要用户链接数据库,比如要输入密码啊,要输入数据库名称啥的还行但是时间长了,有点麻烦,我就想做一个功能,类似QQ登陆保存用户名 保存密码一样的比如在用户名的,或者数据库名字后面有一个checkBox,选择以后,以后再登陆就不用再输入了,就能直接登陆啥的了-----------------------------------------就是为了达到找个功能,我没啥思路,也没啥办法,还请高手赐教一下,谢谢了!!
调试欢乐多
就是这样了。
WritePrivateProfileString()
using System;
using System.Data;
using System.IO;
using System.Text;public void WriteFile(string content, string fileSavePath)
{
if (System.IO.File.Exists(fileSavePath))
{
System.IO.File.Delete(fileSavePath);
}
using (System.IO.FileStream fs = System.IO.File.Create(fileSavePath))
{
byte[] info = new System.Text.Encoding.GetEncoding("gb2312").GetBytes(content); //防止乱码
fs.Write(info, 0, info.Length);
}
}
public string ReadFile(string fileOpenPath)
{
if (!System.IO.File.Exists(fileOpenPath))
{
return null;
}
using (System.IO.StreamReader sr = System.IO.File.OpenText(fileOpenPath))
{
return sr.ReadToEnd().ToString();
}
}上面是文件读写代码,若要加密,就只有自己写加密方式了
或config文件保存数据
XML文件操作