基本上我想复制一个文件夹中的所有内容,不包括一个文件夹,这恰好是为我的程序存储日志的地方。(我知道我可以将日志存储在其他地方,但我有我的理由)。到目前为止,我有:
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