Tag: locked files

SMTP发送正在锁定我的文件 – c#

我有一个function,发送消息(很多)和他们的附件。 它基本上循环遍历目录结构,并从文件结构创建电子邮件 c:\emails\message01 \attachments c:\emails\message02 \attachments 使用.net c#,标准内容创建消息。 创建完所有消息后……我有另一个直接运行的函数,它将消息文件夹复制到另一个位置。 问题是 – 文件被锁定了…… 注意:我没有移动文件,只是复制它们…. 有关如何使用c#复制锁定文件的任何建议? 更新 我有这个添加附件方法 private void AddAttachments(MailMessage mail) { string attachmentDirectoryPath = “c:\messages\message1”; DirectoryInfo attachmentDirectory = new DirectoryInfo(attachmentDirectoryPath); FileInfo[] attachments = attachmentDirectory.GetFiles(); foreach (FileInfo attachment in attachments) { mail.Attachments.Add(new Attachment(attachment.FullName)); } }