using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Program manger = new Program();
manger.CopyPicToFileDirectory("E:\\资讯抓取\\Images", "E:\\资讯抓取\\图片");
}
private void CopyPicToFileDirectory(string sourcePath, string desPath)
{
string[] dirs1 = null;
string[] dirs2 = null;
bool desFileDirectory = System.IO.Directory.Exists(desPath);
if (desFileDirectory == false)
{
Directory.CreateDirectory(desPath);
}
dirs1 = Directory.GetDirectories(sourcePath);
for (int i = 0; i < dirs1.Length; i++)
{
try
{
dirs2 = Directory.GetFiles(dirs1[i]);
for (int j = 0; j < dirs2.Length; j++)
{
FileInfo file = new FileInfo(dirs2[j]);
string filename = file.Name;
file.CopyTo(desPath + "\\" + filename, true);
}
}
catch (Exception ex)
{
Console.Write(ex.Message);
continue;
}
}
}
}
}