[英]Abcpdf HttpContent.Create FileNotFoundException in ASP.net mvc context but file exist
我使用Abcpdf,
有时在创建HttpMultipartMimeForm之后,当HttpContent.Create(
方法使用路径使用
此代码大部分时间都运行良好
PDF是在上下文中创建的
A和B在同一台计算机上,并且共享相同的目录。
我以为我尝试访问该文件时文件还没有写完。 但是如何解决呢?
谢谢。
1.服务器A
using (HttpClient pdfClient = new HttpClient("http://" + ConfigurationManager.AppSettings["xxx"]))
{
using (HttpResponseMessage message = pdfClient.Get(UrlDictionary.callxxx(xxxID, xxxID)))
{
message.EnsureStatusIsSuccessful();
message.Content.ReadAsStream();
}
}
2.服务器B
theDoc.Save(HostingEnvironment.ApplicationPhysicalPath + "/xxx/" + ".pdf");
theDoc.Clear();
3.服务器A
HttpMultipartMimeForm request = new HttpMultipartMimeForm();
FileInfo info = new FileInfo(pathFile);
HttpFormFile file = new HttpFormFile();
file.Content = **HttpContent.Create(info, "multipart/form-data")**; (Exception FileNotFoundException)
file.FileName = info.Name;
file.Name = "file";
request.Files.Add(file);
request.Add("id", id);
using (HttpResponseMessage response = client.Post(
string.Format("/xxx/{0}", id),
request.CreateHttpContent()))
{
ExceptionIfBadRequest(response);
Contrat contrat = (Contrat)FromXml(response.Content.ReadAsString(), typeof(Contrat));
return contrat;
}
检查PDF文件和目录的权限,检查文件没有附加“区域”信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.