//获得Folder的路径
string path = System.AppDomain.CurrentDomain.BaseDirectory + "Folder";
//获得Folder的路径下所有的txt文件
string[] txtArr = System.IO.Directory.GetFiles(path);
using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
{
conn.Open();
if (conn.State == ConnectionState.Open)
{
//循环读取Folder文化夹下所有的txt文件内容
for (int i = 0; i < txtArr.Length; i++)
{
//读出txt内数据
using (StreamReader SR = System.IO.File.OpenText(txtArr[i]))
{
string sql = SR.ReadToEnd();
//将无网络状态下执行的动作提交数据库
// DbHelperSQL.ExecuteSqlClosed(sql);
}
//提交数据后删除txt文件
System.IO.File.Delete(txtArr[i]);
}
}
else
{
Response.Write("<script>未连接到网络服务器,请您查看网络</script>");
return;
}
}
Response.Write("<script>数据提交服务器成功!</script>");