473,739 Members | 6,655 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

weird....differ ent size between uploading and downloading???

TJ
Hi,

I've written code web-based uploading and downloading.
Here is some code for it.

For saving file into MS-SQL database,
SaveFileIntoDB( HttpPostedFile file) {
int fileLength = file.ContentLen gth;
byte[] fileContent = new byte[fileLength];
int lastPos = file.FileName.L astIndexOf('\\' );
fileName = file.FileName.S ubstring(++last Pos);
file.InputStrea m.Read(fileCont ent,0,fileLengt h);
String fileContentType = file.ContentTyp e;

// Save fileLength,file Name and fileContent into MS-SQL database
// data type of fileLength(colu mn name : filelength) is int
// data type of fileName(column name : filename) is varchar(100)
// data type of fileContent(col umn name : filecontent) is image.
// data type of fileContent type(column name : contenttype) is
varchar(100)

DB.Save(......) ;

}

For downloading the file from the DB.

Download() {

// Fetch the file info into db variable from the DB.

int filesize = Convert.ToInt32 (db["filesize"].ToString());
byte[] fcontent = db["fileconten t"] as byte[];
ms = new MemoryStream();
ms.Position = 0;
ms.Write(fconte nt,0,fcontent.L ength);
Response.Append Header("Content-Disposition",
"filename=" + db["filename"].ToString());
Response.Conten tType = db["contenttyp e"].ToString();
Response.Output Stream.Write(ms .GetBuffer(),0, Convert.ToInt32 (ms.Length));
}

For saving the file info to the sql db, it worked as I expected. Also, when
I tried to download the file that I saved into the db, it worked, HOWEVER,
when I checked the filesize, it was DIFFERENT. Do you have any idea why?

For example,

Suppose that I uploaded "A.exe" file into the sql db.
The file size of A. exe was 5113 Bytes.
If I downloaded the A.exe, and then when I checked the file size,
it was 5,896 Bytes.
I think that it should be same size since it was same file.
Always whenever I download the file that I've uploaded, the file size is
slighlty bigger than uploaded file. I really couldn't find any reason....
After downloading, the file seems like working well, but I guess it must be
something wrong since it was different file size.

If you could give any ideas about this issue, I really appreciate it.

Thanks.

Nov 18 '05 #1
0 1519

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2079
by: redneck_kiwi | last post by:
Hi all: I have a really weird problem. I am developing a customer catalog system for my company and as such have delved into sessions for authentication and access levels. So far, I have managed to get a working system just about finished. I am building an interface for our customer service folks to use to manage registered customers and am seeing some weird behavior.
7
3401
by: LRW | last post by:
Below I'll paste my CSS and the HTML in question. But what's happening is, I'm trying to establish a link behavior for a class that's separate from the normal link class. I've established a: 's with no underline and then an underline for hover...but oddly, only ONE link will actually show the underline on hover. All the rest, even with the same HTML, won't pop up an underline. I just don't get it! If I could get any advice I'd really...
5
4012
by: news | last post by:
I've a site: http://gto.ie-studios.net/products.php that looks perfectly fine in Windows whether with IE or Firefox 1.0. But when viewed in the Linux version of Firefox 1.0, images get misaligned and breaks between then appear. Why the two different behaviors on the same browser but different OS's? Anyway, that page as an example DOES W3C HTML validate AND W3C CSS validate as well. So, there's no ERRORS per se, but I suppose there's...
4
2153
by: Himanshu | last post by:
hi, Can anybody tell me that thru asp.net using c#, how can we upload and download physical files in any table of SQL Server Database. the uploading part is running successfully but the problem arises in the retriving part of the code. i am not getting that how will i able to download the file which is there in the SQL Server database in the field type "image".
2
3514
by: Verde | last post by:
I currently let users upload files (graphics) to a Web site. I want to limit the size of graphics, so I have the following in Web.config <httpRuntime maxRequestLength="110" /> That works just fine. But now I want to add another page where the users can upload a file. This time an Excel file. I'd like to enable uploading Excel files larger than 110K, so how can I enable that while keeping the 110K limit on graphics?
11
9574
by: Parrot | last post by:
Is there any routine I can call to reduce the size of an image file after uploading a file from a client. I am looking to reduce file sizes programmatically using C# in my web page after uploading. I know that Photoshop can do it but I need to do it dynamically in my web page. I tried doing it myself with some of the Bitmap thumbnail instructions but the resulting image is very bad. I need a file reduction routine that creates a good image...
3
4932
by: J055 | last post by:
Hi How do I tell the user he has tried to upload a file which is too big... 1. when the httpRuntime.maxRequestLength has been exceeded and 2. when the uploaded file is under then httpRuntime.maxRequestLength For point 1. it would be good to at least display a nice error page. IE seems to just display a blank page.
5
7059
by: Steve | last post by:
WSE352 Size of the record exceed its limit I have a C#.Net windows app that calls a FileNet web service. I can run a select against the web service and it returns up to 7,200 records with 5 columns each. When I try to select more rows I get a WSE352 "The size of the record exceed its limit." I think I am at the default 4 mb download limit. I am using WSE2.0 on dotNet Framework 1.1. I have tried changing the machine.config in the...
4
8702
by: aldonnelley | last post by:
Hi there: a bit of a left-field question, I think. I'm writing a program that analyses image files downloaded with a basic crawler, and it's slow, mainly because I only want to analyse files within a certain size range, and I'm having to download all the files on the page, open them, get their size, and then only analyse the ones that are in that size range. Is there a way (in python, of course!) to get the size of images before or...
0
8969
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9479
Oralloy
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...
0
9337
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9266
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,...
0
9209
tracyyun
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...
1
6754
isladogs
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...
0
4570
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...
0
4826
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2193
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.