0
我有解決方案「解決方案」和兩個項目:訪問文件
- solution.WebUI(這裏用戶上傳文件到像「〜/上傳」某個文件夾
- solution.WebApi(這裏我必須訪問用戶文件)
在網頁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;
}
如何修改文件路徑?
我不明白。 – 2013-03-18 16:45:16