自从asp.net升级到net7.0后,我的www.example.com网站出现了问题。
我将一个pdf加载到临时目录中,并想将其附加到电子邮件中。
// upload invoice to computer
var httpClient = new HttpClient();
var responseStream = await httpClient.GetStreamAsync("..site.com/.../uploads/" + invoice.PfadRel + "");
using var fileStream = new FileStream(@"C:\Temp\Invoice-" + invoice.no + ".pdf", FileMode.Create, (FileAccess)FileShare.ReadWrite);
responseStream.CopyTo(fileStream);
// attach invoice to mail
builder.Attachments.Add(@"C:\Temp\Invoice-" + invoice.no + ".pdf");
不幸的是,带有“builder.Attachments.”的行生成错误消息:
IOException: The process cannot access the file because it is being used by another process.
有人知道这里出了什么问题吗?
1条答案
按热度按时间pieyvz9o1#
@CodeMaster:这就是暗示。
这解决了我的问题: