0

这是我尝试以二进制格式存储上传文件的数据的代码............

protected void Button1_Click(object sender, EventArgs e)
{
int PartyRowId = 0;
foreach (UploadedFile file in AsyncUpload1.UploadedFiles)

{
    byte[] bytes = new byte[file.ContentLength];
    file.InputStream.Read(bytes, 0, Convert.ToInt32(file.ContentLength));
    string json3 = "{'value1':" + value+ ",'value2':" + value+ ",'value3':" + value+ ",'PartyDoc':" + bytes + "}";

}
}


我得到了Json

 {'value1':0,'value2':0,'value3':0,'PartyDoc':System.Byte[]}


无法检索二进制数据请帮助我......

4

2 回答 2

0

完成如下转换...

转换(varbinary(100),转换(varchar(最大值),@variable))

于 2015-01-10T10:04:29.330 回答
0

你应该使用Convert.ToBase64String();

string json3 = "{'value1':" + value+ ",'value2':" + value+ ",'value3':" + value+ ",'PartyDoc':" + Convert.ToBase64String(bytes) + "}";

然后在另一边你可以使用Convert.FromBase64String();

于 2015-01-10T06:16:41.833 回答