Click here to Skip to main content
15,991,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello all,
I have a image path and a table in database that contains image column
How can I get the image and convert it to binary, so I can store it in database??
Posted
Comments
Sergey Alexandrovich Kryukov 11-Feb-15 15:19pm    
Image is already "binary"...
—SA

 
Share this answer
 
v2
Comments
TheRealSteveJudge 11-Feb-15 10:38am    
5*
You can read the bytes from the file using the File.ReadAllBytes[^] method and then store those in your database.
C#
byte[] imageData = File.ReadAllBytes(filePath);
// store imageData in database
 
Share this answer
 
Comments
TheRealSteveJudge 11-Feb-15 10:38am    
5*
Thomas Daniels 11-Feb-15 10:45am    
Thank you!
See this CP article: C# Save and Load Image from Database[^]

/ravi
 
Share this answer
 
Save, Resize, and Convert to Binary:
Image in C#: Save, Resize, and Convert to Binary[^]
Hope helpful !
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900