asp.net - 该进程无法访问文件“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));
它有什么问题?
解决方案
推荐阅读
- powershell - powershell 命令的输出只显示一列
- c - 带指针的 C sprintf 实现
- fonts - 如何增加 Google colab 单元格输出的字体大小?
- mysql - 根据出现次数返回记录
- reactjs - 无法使用 React 在 App.js 中呈现子组件
- r - 如何在 R 中找到 R^d 上的函数的水平集?
- angular - 角度搜索过滤器(由字符串数组组成)
- java - 我是否必须保持导航图中的片段 ID 与菜单项 ID 相同?
- typescript - AWS CDK - 不能在构造 ID 中使用令牌 - 如何根据其他构造的名称动态命名构造?
- c# - TFS 自动关联 ID 未提供的其他工作项