0
ここAsp.net APIからのファイルのダウンロード中のエラーは私 が指定されたパスの形式はサポートされていません。
public HttpResponseMessage GetTestFile()
{
HttpResponseMessage result = null;
// var localFilePath = HttpContext.Current.Server.MapPath(@"~/C:/Temp/3c575edb-bf53-470c-a8b6-aa4234e796c0");
var localFilePath = HttpContext.Current.Server.MapPath(@"~/C:/Temp/3c575edb-bf53-470c-a8b6-aa4234e796c0");
if (!File.Exists(localFilePath))
{
result = Request.CreateResponse(HttpStatusCode.Gone);
}
else
{
// Serve the file to the client
result = Request.CreateResponse(HttpStatusCode.OK);
result.Content = new StreamContent(new FileStream(localFilePath, FileMode.Open, FileAccess.Read));
result.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment");
result.Content.Headers.ContentDisposition.FileName = "SampleImg";
}
return result;
}
はい、私のプロジェクト – Hussain
内でそのprsenet型「System.NotSupportedException」の例外は、これはEXAMPLE.SQLのファイルを検索します//がmscorlib.dllで発生したが、ユーザーコード – Hussain
で処理されていませんでしたルートディレクトリに保存します。 // ...これは、アプリケーションの任意のディレクトリにあるファイルで使用できます。 'string localFilePath = HttpContext.Current.Request.MapPath("〜/ Example.txt ");'。考えましたか?だからあなたのケースでは '3c575edb-bf53-470c-a8b6-aa4234e796c0'フォルダですか? –