Converting System.Data.LINQ.Binary to an ASCII Encoded String
I ran into a situation where I was storing files in a database as a binary field. Some of these files were in HTML format and I wanted to dynamically display them inside of some ASP pages I was developing. After a bit of research I was finding a lot of other solutions people were using involved timestamp conversions which were not ASCII based like HTML. The following code will convert your binary object into ASCII and display it as it was originally uploaded.
byte myByteArray = myBinaryObj.ToArray(); System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); string result = enc.GetString(myByteArray);