C
C#5mo ago
Kaygee

Convert a Binary string to a file

Hello Guys, I created this code which convert a text file to be copied into a image field in SQL server FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read); BinaryReader reader = new BinaryReader(stream); byte[] Fichier = reader.ReadBytes((int)stream.Length); reader.Close(); stream.Close(); return Fichier; How can I do the inverse ? I would get the binary from sql and copy content into a file Thanks
3 Replies
canton7
canton75mo ago
File.WriteAllBytes? (and File.ReadAllBytes would be a lot easier than what you're doing)
mindhardt
mindhardt5mo ago
Also prefer async versions of those methods
canton7
canton75mo ago
Eh, depends on the context

Did you find this page helpful?