62,244
社区成员




public async Task<HttpResponseMessage> Getxx()
{
try
{
string path = @"c:\0.xlsx"; //Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Export\\list.txt");
if (!string.IsNullOrWhiteSpace(path) && File.Exists(path))
{
string filename = Path.GetFileName(path);
var stream = new FileStream(path, FileMode.Open);
HttpResponseMessage resp = new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StreamContent(stream)
};
resp.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
{
FileName = filename
};
resp.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
resp.Content.Headers.ContentLength = stream.Length;
return await Task.FromResult(resp);
}
}
catch (Exception ex)
{
}
return new HttpResponseMessage(HttpStatusCode.NoContent);
}