Re: Extracting binary file from sql database image field to disk
Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Thu, 2 Aug 2007 21:17:27 +0100
Scott <Scott@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
I am trying to extract a zip file in a database image field to disk. For some
reason, the zip file is getting corrupted / truncated. I have code in ASP
which extracts the zip file no problem, so i know it is not corrupted in the
table. Any help would be appreciated.
FileStream fs = new FileStream(sFilePath + "TestFile.zip",
FileMode.CreateNew);
BinaryWriter bw = new BinaryWriter(fs);
byte[] buffer =
Encoding.ASCII.GetBytes(DataReader[sField].ToString());
bw.Write(buffer);
bw.Close();
fs.Close();
Don't convert the binary data to a string - that's a recipe for a
disaster.
If you look at DataReader[sField].GetType(), what does it say?
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog:
http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.
Relevant Pages
- Re: very confused....hex to decimal
... Gerald ... the reason i know it should be 685630.9500000000 is that i ... >>> lance ... (microsoft.public.dotnet.languages.vb) - Re: Image::Magick and perl script STDOUT problem
... script is being executed server side. ... I unsderstand in my example their ... is no reason to be using imagemagick. ... that is supposed to write the binary data to STDOUT, ... (comp.lang.perl.misc) - Re: [splot] matrix binary or ASCII File ?
... I'll peer at the source code to see if ... this was necessary for some reason. ... It's necessary because binary data have no record separator ... The rest of the format flows sort-of naturally from that. ... (comp.graphics.apps.gnuplot) - Re: Form select multiple question
... this does not behave as a multiple select. ... > The form is also posting binary data for upload to the server. ... Probably an ASP issue. ... If you select multiple options and submit, ... (alt.html) - Re: Speed way to detect if an IP exists
... Even calling a different asp page that just returns a status isn't going to help much. ... It'd be better to call the one asp page and if it has troubles it returns a timeout or status message before the other binary data. ... But if you want just a speedy way to test the server then I'd put a different asp page on there, or change the parameters so as it returns immediately. ... (microsoft.public.vb.general.discussion) |
|