這裏,試試這個:
編輯:我的回答適用於本地網絡目錄,我不提,你想從HTTPS複製directiories,爲您必須使用Web客戶端與Credenti ALS
class DirectoryCopyExample
{
string pathFrom = "C:\\someFolder";
string pathTo = "D:\\otherFolder";
string LogText = string.Empty;
static void Main()
{
// Copy from the current directory, include subdirectories.
DirectoryCopy(pathFrom, pathTo, true);
}
private static void DirectoryCopy(string sourceDirName, string destDirName, bool copySubDirs)
{
// Get the subdirectories for the specified directory.
DirectoryInfo dir = new DirectoryInfo(sourceDirName);
DirectoryInfo[] dirs = dir.GetDirectories();
if (!dir.Exists)
{
throw new DirectoryNotFoundException(
"Source directory does not exist or could not be found: "
+ sourceDirName);
}
// If the destination directory doesn't exist, create it.
if (!Directory.Exists(destDirName))
{
Directory.CreateDirectory(destDirName);
}
// Get the files in the directory and copy them to the new location.
FileInfo[] files = dir.GetFiles();
foreach (FileInfo file in files)
{
try
{
string temppath = Path.Combine(destDirName, file.Name);
file.CopyTo(temppath, false);
}
catch(Exception)
{
//Write Files to Log whicht couldn't be copy
LogText += DateTime.Now.ToString() + ": " + file.FullName;
}
}
// If copying subdirectories, copy them and their contents to new location.
if (copySubDirs)
{
foreach (DirectoryInfo subdir in dirs)
{
string temppath = Path.Combine(destDirName, subdir.Name);
DirectoryCopy(subdir.FullName, temppath, copySubDirs);
}
}
}
}
你必須變量LogTex保存到文件末尾,或任何你需要
來源:http://msdn.microsoft.com/en-us/library/bb762914(v=vs.110).aspx
你有沒有嘗試任何代碼?看起來你會想從源代碼到目的地執行遞歸文件複製。 –