Mitchell Mitchell - 2 months ago 6x Question

How to download a Byte Array?

So, using, I retrieve from my server the byte data for a file that the user wishes to download. I always know what the filename and extension is, but what I don't know is how to start downloading the byte data and in the proper file format. How do I got about doing this?

EDIT: Just to clarify, I already retrieve the data in byte format in code, I just need to download it as the proper file type which is also known. I'm keeping the URL to the file hidden at all times so it's never exposed.


Okay, I figured it out. Using BinaryWrite with the other Response functions like AddHeader and ContentType I got it to work. GetMimeType is a function I made. Code below:

Response.AddHeader("Content-Disposition", "attachment; filename=" + FileName)
Response.ContentType = GetMimeType(FileName)

Thanks to those who tried to help!