Search code examples
c#radupload

Need to store the data in Binary format for the Uploaded file using RADUPLOAD


Here is the code I tried to store the data in binary format for the uploaded file...................

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 + "}";

}
}


i got the Json as

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


not able to retrieve the binary data Please help me......


Solution

  • You should use Convert.ToBase64String();

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

    Then on the other side you can useConvert.FromBase64String();