基本的に、プログラムのログが保存される場所である 1 つのフォルダーを除いて、フォルダー内のすべてをコピーしたいと考えています。(ログを別の場所に保存できることはわかっていますが、理由があります)。これまでのところ、私は持っています:
private void btnCopyFiles_Click(object sender, EventArgs e)
{
try
{
//Copy all the files
foreach (string newPath in Directory.GetFiles(@"\\xxx\yyy", "*.*",
SearchOption.AllDirectories)
.Where(p => p != Logging.fullLoggingPath))
File.Copy(newPath, newPath.Replace(@"\\xxx\yyy", @"C:\bbb"));
using (StreamWriter w = File.AppendText(Logging.fullLoggingPath))
{
Logging.Log("All necessary files copied to C:\\bbb", w);
}
}
catch
{
using (StreamWriter w = File.AppendText(Logging.fullLoggingPath))
{
Logging.Log("Error copying files, make sure you have permissions to access the drive and write to the folder.", w);
}
}
}
これを変更して、特定のフォルダーを除外するにはどうすればよいですか\\xxx\yyy