【发布时间】:2014-02-01 06:20:26
【问题描述】:
string savePath = Server.MapPath("\\Upload_File\\");
// Get the name of the file to upload.
string fileName = email_attach.FileName;
string pathToCheck = savePath + fileName;
email_attach.SaveAs(pathToCheck);
string file = pathToCheck;
Attachment data = new Attachment(file);
mail.Attachments.Add(data);
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("username", "password");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
email_attach.Dispose();
FileInfo file_Delete = new FileInfo(pathToCheck);
if (file_Delete.Exists)
{
file_Delete.GetAccessControl();
file_Delete.Delete();
}
当我这样做时,它会抛出异常
在 mscorlib.dll 中发生了“System.IO.IOException”类型的异常,但未在用户代码中处理
附加信息:该进程无法访问文件“C:\Users\User\Documents\Visual Studio 2013\WebSites\Email_Sent_Web\Upload_File\DMP.edx”,因为它正被另一个进程使用。
我如何解决请帮助,谢谢提前
【问题讨论】: