读写文本文件,乱码解决方案
摘要:在对文本文件进行读取的时候,如果其中包含了中文,可能就会有乱码的出现,解决方法很简单。只需要在读取出来的时候StreamReader加一个编码就可以了。代码如下: using System.IO; StreamReader sr = new StreamReader(fileName,Encoding.GetEncoding("gb2312"));//fileName为文件的绝对路径 由于C#...
阅读全文
posted @
2018-01-24 12:13
ghgxm520
阅读(407)
推荐(0)
MD5加密
摘要:public static string GetMD5(string str) { //定义接受加密后的字符串 string md5Str = null; //创建MD5加密实例 MD5 md5 = MD5.Create(); //将密码参数转成字节数组 ...
阅读全文
posted @
2018-01-24 11:51
ghgxm520
阅读(132)
推荐(0)
将DataTable导入到SQL数据库表中
摘要:/// /// 将DataTable导入到SQL数据库表中 /// /// DataTable 数据源 /// SQL连接字符串 public static void DataTableToSQLServer(DataTable dt, string connectString) { ...
阅读全文
posted @
2018-01-19 14:59
ghgxm520
阅读(395)
推荐(0)
NPOI组件操作Excel导入、导出
摘要:/// /// 将xls格式的Excel读取到DataTable中 /// /// 文件路径 /// public DataTable HSSFReadExcel(string fileName) { try { ...
阅读全文
posted @
2018-01-19 11:48
ghgxm520
阅读(198)
推荐(0)