[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

 

You are viewing reply posted by: Mudassar one year ago.
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)