一个用于整体移动文件夹的方法,简练实用
http://blog.csdn.net/guoxubin2005/article/details/4154095
一个用于整体移动文件夹的方法,简练实用:
public static void CopyDirectory(string sourceDirName, string destDirName)
{
if (!Directory.Exists(destDirName))
{
Directory.CreateDirectory(destDirName);
File.SetAttributes(destDirName, File.GetAttributes(sourceDirName));
}
if (destDirName[destDirName.Length - 1] != Path.DirectorySeparatorChar)
{
destDirName = destDirName + Path.DirectorySeparatorChar;
}
string[] files = Directory.GetFiles(sourceDirName);
foreach (string file in files)
{
File.Copy(file, destDirName + Path.GetFileName(file), true);
File.SetAttributes(destDirName + Path.GetFileName(file), FileAttributes.Normal);
}
string[] dirs = Directory.GetDirectories(sourceDirName);
foreach (string dir in dirs)
{
CopyDirectory(dir, destDirName + Path.GetFileName(dir));
}
}