當我使用此代碼時,它不會拋出任何錯誤,但它仍然不會複製任何內容。有任何想法嗎?。File.Copy - DirectoryNotFoundException未處理
//string spath = string.Format("S:\\ 0A36303/user:admin");
DateTime theDate = dateTimePicker1.Value.Date;
DirectoryInfo Dir = new DirectoryInfo("S:");
string dircreate = string.Format(@"N:\{0:MM-dd-yyyy}\" + label1.Text + "LogFiles", dateTimePicker1.Value.Date, label1.Text);
DirectoryInfo target = new DirectoryInfo(dircreate);
FileInfo[] fis = Dir.GetFiles(".txt", SearchOption.AllDirectories);
foreach (FileInfo fi in fis)
{
if (fi.LastWriteTime.Date == theDate)
{
File.Copy(fi.FullName, target.FullName + @"\" + fi.Name, true);
}
}
}
}
}
您能否確認S:\ pc.log存在 –
是文件存在,但該文件實際上名爲pchost.txt和pcaudit.txt。 – user1836162