Reputation: 8350
I have a console application using C# where I want to read the blob stored in SQL Server and write it to windows file system at a specified path.
How do I convert a blob to a image of pdf using C# and write it to a file system?
Upvotes: 1
Views: 7226
Reputation: 150
What kind of blob are we talking about here? Assuming you are using .NET, Check out SqlDataReader or Entity Framework. There are other methods as well but those 2 are pretty popular. Converting to PDF you will probably need a 3rd party tool, check out PDF Sharp. Finally, saving to filesystem is pretty straightforward, look at the .NET System.IO.File class
Upvotes: 0
Reputation: 25008
Take a look here: http://www.akadia.com/services/dotnet_read_write_blob.html
Using a DataAdapter / DataSet would most likely prove even easier - if you can afford to have the entire BLOB content loaded into memory for the number of rows you're processing.
Upvotes: 1
Reputation: 499352
Read the blob from the database into a byte[]
and write this buffer to a file.
Upvotes: 1