0
我正在編寫一個程序,該程序查找文件夾中的文件,將文件附加到MailMessage並使用SmtpClient發送電子郵件。發送郵件後移動文件
電子郵件發送成功後,我想將電子郵件文件移動到其他文件夾。
我收到此消息「進程無法訪問文件,因爲它正在被另一進程使用」。我試過Thread.Sleep(),但沒有工作。
smtpClient.Send(mail);
foreach (var report in reports)
{
string source = Path.Combine(reportsFolder, report);
string destination = Path.Combine(sentReportsFolder, report);
File.Move(source, destination);
}
你是如何將文件附加到消息? – Amy