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

Last Reply one year ago By Mudassar

Posted one year ago


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.



Posted one year ago

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


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


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