我有解决方案“解决方案”和两个项目:
- solution.WebUI(这里用户将文件上传到某个文件夹,如“~/uploads”
- solution.WebApi(这里我必须访问用户文件)
在 web api 项目中,我访问如下文件:
public HttpResponseMessage GetPdfPage()
{
HttpResponseMessage responce = new HttpResponseMessage();
responce.Content = new StreamContent(new FileStream(HttpContext.Current.Server.MapPath("~/somefile.pdf"), FileMode.Open, FileAccess.Read));
responce.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
return responce;
}
我必须如何修改文件路径?