相关疑难解决方法(0)

将文件从一个目录复制到另一个目录的最快方法

我需要将文件从一个目录复制到另一个目录,具体取决于SQL数据库表中是否存在文件名.

为此,我使用以下代码:

using(SqlConnection connection = new SqlConnection("datasource or route"))
{

  connection.Open();

  using(SqlCommand cmd = new SqlCommand("SELECT idPic, namePicFile FROM DocPicFiles", connection))
  using (SqlDataReader reader = cmd.ExecuteReader())
  {

    if (reader != null)
    {
      while (reader.Read())
      {
        //picList IS AN ARRAY THAT Contains All the files names in a directory
        if (picList.Any(s => s.Contains(reader["namePicFile"].ToString())))
        {
          File.Copy("theFile  in the Directory or array picList",  "the destiny directory"+ ".jpg", false)
        }
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

有没有什么办法可以在更短的时间内完成?这需要1小时,为20.876记录.

c# system.io.file

1
推荐指数
3
解决办法
8625
查看次数

标签 统计

c# ×1

system.io.file ×1