Tag: httpcontent

C#无法将欧元符号打印到文件中(使用Excel打开时)

我有一个get方法到一个web api控制器的问题。 此方法返回一个HttpResponseMessage对象,该对象具有包含欧元符号的csv文件的HttpContent。 当该方法返回文件时,欧元符号不被打印。 该方法的代码如下: string export = … //string with fields separed by ';' and with euro symbol HttpResponseMessage response = new HttpResponseMessage(); UTF8Encoding encoding = new UTF8Encoding(); Byte[] buffer = encoding.GetBytes(export); response.Content = new ByteArrayContent(buffer); response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/csv"); response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = "Export.csv" }; response.Content.Headers.ContentLength = export.Length; response.Content.Headers.Expires = […]