首页 > 解决方案 > 该进程无法访问文件“C:\FolderStructure\APP\pic.jpg”,因为它正被另一个进程使用。网

问题描述

下面的代码浏览/附加文档并通过电子邮件发送,执行时返回 IOexception。

if (inpAttachment1.PostedFile != null)
{
   HttpPostedFile attFile = inpAttachment1.PostedFile;
   int attachFileLength = attFile.ContentLength;
   if (attachFileLength > 0)
   {
       strFileName = Path.GetFileName(inpAttachment1.PostedFile.FileName);
       inpAttachment1.PostedFile.SaveAs(Server.MapPath(strFileName));
       Attachment attach = new Attachment(Server.MapPath(strFileName));
       mail.Attachments.Add(attach);
       attach1 = strFileName;
    }
 }

 objClient.Send(mail);

 if (attach1 != null)
   File.Delete(Server.MapPath(attach1));

我在下面的代码行中得到了 IOexception。

inpAttachment1.PostedFile.SaveAs(Server.MapPath(strFileName));

它有什么问题?

标签: asp.netioexception

解决方案


推荐阅读