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(sFil ePath + "TestFile.z ip",
FileMode.Create New);
BinaryWriter bw = new BinaryWriter(fs );
byte[] buffer =
Encoding.ASCII. GetBytes(DataRe ader[sField].ToString());
bw.Write(buffer );
bw.Close();
fs.Close(); 5 9137
Scott <Sc***@discussi ons.microsoft.c omwrote:
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(sFil ePath + "TestFile.z ip",
FileMode.Create New);
BinaryWriter bw = new BinaryWriter(fs );
byte[] buffer =
Encoding.ASCII. GetBytes(DataRe ader[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 - <sk***@pobox.co m> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Matt F <mf************ ****@nospam.nos pamwrote:
I use the binaryformatter class for this type of thing --- MSDN example for
the binaryformatter class has a pretty good example.
It's a zip file - natural binary data to start with. Serializing it
would add an extra layer for no good reason, *and* make it
hard/impossible to use from other platforms.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
"Jon Skeet [C# MVP]" wrote:
Scott <Sc***@discussi ons.microsoft.c omwrote:
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(sFil ePath + "TestFile.z ip",
FileMode.Create New);
BinaryWriter bw = new BinaryWriter(fs );
byte[] buffer =
Encoding.ASCII. GetBytes(DataRe ader[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 - <sk***@pobox.co m> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
The DataReader[sField].GetType() comes back as System.String
Scott <Sc***@discussi ons.microsoft.c omwrote:
If you look at DataReader[sField].GetType(), what does it say?
The DataReader[sField].GetType() comes back as System.String
Okay, that's a bad start. What's the data type in the database, and how
have you stored the zip file in there in the first place? Storing a
binary block of data (such as a zip file) in a text field is a really
bad move...
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ringo Langly |
last post by:
Hi folks,
Is it possible to store Binary Files in MS SQL 2000 ??? Say I have a
100K PDF or a 150K word document. Is it possible to store this in a
field in MS SQL and pull it out somehow? We're using ColdFusion on the
server on Apache.
Thanks,
Ringo
|
by: deko |
last post by:
I have a table that contains a bunch of pictures. When the user selects a
particular image in a form, I need a way to extract the selected bitmap
image (stored in an OLE Object table field) to the file system so the user
can do stuff with "somePicture.bmp", for example.
Is there an easy way to do this?
Thanks in advance.
|
by: Denise Smith |
last post by:
Hello,
I'm wondering if anyone can help me out here?
I want to be able to browse records in a database where one of the
fields contains an image.
I think I might have to extract the image to a byte array, write it to
a temp file then refer to the temp file as the URL source for the
Image control.
|
by: Arun |
last post by:
Hi,
I have simple question to ask. How to write multiple Binary files to the
Browser using Asp.Net and Visual C#.net
I have seen examples where single binary file is written to browser.
-Regards
Arun
|
by: Terry Olsen |
last post by:
Ok, now that I've got my disk imager program working, I'd like to attach a
"self-extractor" to the front end of the image file and make it a
self-extracting disk image executable file. The idea being that the user
would double-click on the file and the disk would be created. I would like
to be able to "create" the self-extracting disk image from my program. Any
guidance on how to go about doing this?
thanks.
| |
by: Water Cooler v2 |
last post by:
There are two datatypes for storing binary data type in the SQL Server:
1. binary - for fixed length binary data
2. varbinary - for variable length data
My question is: how is data inserted into them? Do they have any
delimiters that go into the insert statement like strings and datetimes
have? What format (hex/decimal?) do they accept data in? Can you please
give me an insert statement example?
|
by: Dave |
last post by:
Hello,
I am wondering about including binary files in my MS Access database
application. I want to keep my application as just a single MDE or MDB
file, but the users of the app may need some additional files. One file
is an ODBC driver for connecting to an external database, this is a 120
kb DLL. The other is a 20 kb PDF help document for using the database
application. I am wondering if it is possible to store these files
within...
|
by: lawrence k |
last post by:
I'm a little weak on my basic I/O. Help me out please.
Is it right to say that I can just open any file with file(), get it as
a string, and then store in a MySql database, in, say, a MediumText
field? I realize that MySql supports binary fields, but my current
MySql schema does not have any binary fields, and I'm wondering if I
can store the file without changing my current schema.
Can I recreate the file later, if I wish, just be...
|
by: nicolasg |
last post by:
Hi,
I'm trying to open a file (any file) in binary mode and save it inside
a new text file.
After that I want to read the source from the text file and save it
back to the disk with its original form. The problem is tha the binary
source that I extract from the text file seems to be diferent from the
source I saved. Here is my code:
1)
handle=file('image.gif','rb')
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |