日期:2014-05-17 浏览次数:20734 次
string FilePath = @"F:\360云盘\手机号码归属地\";
//目标文件夹文件数组
string[] Files = Directory.GetFiles(FilePath);
//循环读取文件
int i = 0;
int j = 0;
foreach (string file in Files)
{
//文件个数
i = i + 1;
//label1.Text = file.Replace(FilePath,"");
string filename = file.Replace(FilePath, "");
//读取文件
using (FileStream PhoneNumber = File.OpenRead(file))
{
//将文件内容以流的形式读取
using (StreamReader streamReader = new StreamReader(PhoneNumber, Encoding.GetEncoding("gb2312")))
{
//数据库连接
using (SqlConnection objConn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFileName=|DataDirectory|\xx.mdf;Integrated Security=True;User Instance=true"))
{
//打开数据库
objConn.Open();
//初始化SQLCommand对象,准备执行SQL
using (SqlCommand objCmd&