Vbscript 如何在经典ASP中将字符串转换为字节数组
我正在尝试下载一个经典的ASP文件。 请查找下面的代码Vbscript 如何在经典ASP中将字符串转换为字节数组,vbscript,asp-classic,Vbscript,Asp Classic,我正在尝试下载一个经典的ASP文件。 请查找下面的代码 set fileDownloadResponse = WebService_FileDownload(FileUri.Value) Response.ContentType = admindata("FileType")//type getting from SQL column Response.Addheader "Content-Disposition", "attachment;fi
set fileDownloadResponse = WebService_FileDownload(FileUri.Value)
Response.ContentType = admindata("FileType")//type getting from SQL column
Response.Addheader "Content-Disposition", "attachment;filename=""" & FileName & """"
Response.BinaryWrite(fileDownloadResponse.value)//**fileDownloadResponse.value**
我从代码返回为Byte[]
,但当它进入ASP页面时,它显示为字符串…我想将字符串转换为字节数组,并将该数组传递到响应中。BinaryWrite(需要传递字节)
尝试使用
Const adTypeBinary = 1
Response.Buffer = False
Dim objStream
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Type = adTypeBinary
objStream.Open
' depends on what fileDownloadResponse is
' you might need to use .Read(), .ReadText() or .LoadFromFile()
objStream.ReadText fileDownloadResponse.value
Response.ContentType = "application/x-unknown" ' what kind of file it is?
Response.Addheader "Content-Disposition", "attachment; filename=""" & FileName & """"
Response.BinaryWrite objStream.Read
objStream.Close
Set objStream = Nothing
private HttpResponseMessage DownloadFileResponse( HttpStatusCode statusCode, Byte[] ContentArray )
{
HttpResponseMessage response = new HttpResponseMessage();
response.StatusCode = statusCode;
response.Content = new ByteArrayContent( ContentArray );//here just convert into byte array content and in Response.BinaryWrite (content) pass this content here to get as byte to doqnlaod it.
return response;
}