Saving Image to a file from database.
-
Hi there, I am trying to save an Image from a database to a file but it only save the following to the file "System.Byte[]".
fileWriter.Write(dsExportDataTypes.Tables[0].Rows[i]["ATTACHMENT"]);
fileWriter
is an object ofStreamWriter
Class.Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."
-
Hi there, I am trying to save an Image from a database to a file but it only save the following to the file "System.Byte[]".
fileWriter.Write(dsExportDataTypes.Tables[0].Rows[i]["ATTACHMENT"]);
fileWriter
is an object ofStreamWriter
Class.Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."
You're using the wrong class.
StreamWriter
is used for writing character data to streams. To save an image to a file, you need to use a class that will handle a binary stream of data. FileStream[^] is the most appropriate class to use. Your code would look like:myFileStream.Write((byte[])dsExportDataTypes.Tables[0].Rows[i]["ATTACHMENT"]);
Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush