我正在使用 ServerXMLHTTP 并使用 HTTPRequester 插件发送请求,我可以看到我的请求的响应是请求文件的原始二进制数据。我需要读取此二进制数据并将其保存在 Byte[] 中,但我不断收到错误消息:当前编码处于无效状态的文件末尾。
这是我的代码:
ServerXMLHTTP HTTPRequest=new ServerXMLHTTP();
HTTPRequest.open("POST",@"https://thetargetwebsite/",false);
HTTPRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
HTTPRequest.send("file_id=" + file_id);
string binaryfile=HTTPRequest.responseText; // causes the error
//OR
System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
byte[] bytes = encoding.GetBytes(HTTPRequest.responseText); // also causes the error
你能帮我看看如何用二进制数据读取响应文本吗?
编辑:如果我不使用 ServerXMLHTTP 我应该改用什么?