[Solved] Convert Byte Array (byte) to HttpPostedFile in C# and VB.Net

Last Reply one year ago By Mudassar

Posted one year ago

Hi,

Kindly help me out. I want to convert byte array back to HttpPostedFile, please tell how?

I want to save the file using HttpPostedFile SaveAs method.

Thanks

 

Posted one year ago

To save Byte Array back to File, you don't need HttpPostedFile, you can easily do using File class.

C#

//Save the Byte Array as File.
string filePath = "~/Files/" + fileName;
System.IO.File.WriteAllBytes(Server.MapPath(filePath), bytes);

VB.Net

'Save the Byte Array as File.
Dim filePath As String = "~/Files/" + fileName
System.IO.File.WriteAllBytes(Server.MapPath(filePath), bytes)