C
C#4mo 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
canton74mo ago
File.WriteAllBytes? (and File.ReadAllBytes would be a lot easier than what you're doing)
mindhardt
mindhardt4mo ago
Also prefer async versions of those methods
canton7
canton74mo ago
Eh, depends on the context
Want results from more Discord servers?
Add your server