Hi,
Im my application, users will upload files to server. I want to impliment GZip to compress files.
But the compressed file is consuming more memory than actual file size.
What might be the problem?
Here is my code - protected void btnCompress_Click(object sender, EventArgs e)
-
{
-
-
if (fUpload.PostedFile == null)
-
{
-
-
lblMessage.Text = "No File Selected to Upload.";
-
}
-
-
string strName = Path.GetFileName(fUpload.PostedFile.FileName);
-
try
-
-
{
-
-
Stream oStream = fUpload.PostedFile.InputStream;
-
-
byte[] buffer = new byte[oStream.Length];
-
-
oStream.Read(buffer, 0, buffer.Length);
-
-
oStream.Close();
-
-
FileStream oFileStream = File.Create(Server.MapPath(Path.ChangeExtension(strName, "gz")));
-
-
GZipStream oGZipStream = new GZipStream(oFileStream, CompressionMode.Compress);oGZipStream.Write(buffer, 0, buffer.Length);
-
oGZipStream.Close();
-
-
lblMessage.Text = "\"" + strName + "\" was compressed & uploaded successfully.";
-
}
-
-
catch (Exception)
-
{
-
-
lblMessage.Text = "An Error Occured While Uploading File.";
-
}
-
-
}
2 1140
Your code seems right,
Maybe you should try DeflateStream instead of GzipStream. Gzip performes CRC , DeflateStream doesn't so this could resolve in a decrease in size. But how much increase are we talking about?
Your code seems right,
Maybe you should try DeflateStream instead of GzipStream. Gzip performes CRC , DeflateStream doesn't so this could resolve in a decrease in size. But how much increase are we talking about?
Hi,
I have tried with Deflate also. While testing, when i upload a 11MB file, its taking 15MB.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: bmgz |
last post by:
I am having problems trying to use the gzip module, I do the followig
>>>import gzip
>>>file = gzip.GzipFile("testfile.txt")
>>>file.write() -which params does this accept?, archive name?
I...
|
by: Xah Lee |
last post by:
today i need to use Python to decompress gzip files.
since i'm familiar with Python doc and have 10 years of computing
experience with 4 years in unix admin and perl, i have quickly located
the...
|
by: comp.lang.php |
last post by:
I am simply trying to zip together selected files into a single ZIP
file. Windows XP doesn't have a native process by which you can do
this, so I borrowed gzip, downloaded and installed, and upon...
|
by: Xah Lee |
last post by:
Python Doc Problem Example: gzip
Xah Lee, 20050831
Today i need to use Python to compress/decompress gzip files. Since
i've read the official Python tutorial 8 months ago, have spent 30...
|
by: Bill |
last post by:
I've written a small program that, in part, reads in a file and parses
it. Sometimes, the file is gzipped. The code that I use to get the
file object is like so:
if filename.endswith(".gz"):...
|
by: Aidan |
last post by:
Hi,
I'm having a bit of trouble with a python script I wrote, though I'm not
sure if it's related directly to python, or one of the other software
packages...
The situation is that I'm trying...
|
by: Nader |
last post by:
Hello,
I have a gzip file and I try to read from this file withe the next
statements:
gunziped_file = gzip.GzipFile('gzip-file')
input_file = open(gunziped_file,'r')
But I get the nezt...
|
by: Nader |
last post by:
Hello,
I have a gzip file and I try to read from this file withe the next
statements:
gunziped_file = gzip.GzipFile('gzip-file')
input_file = open(gunziped_file,'r')
But I get the nezt...
|
by: Gabriel Genellina |
last post by:
En Wed, 19 Nov 2008 13:25:03 -0200, Barak, Ron <Ron.Barak@lsi.com>
escribió:
Note *where* the exception is raised. Until something is actually read, no
check is made for the file format.
--...
|
by: Barak, Ron |
last post by:
Thanks Gabriel,
Okay, I get it: I was under the impression that the format check would be done on the open.
Bye,
Ron.
-----Original Message-----
From: Gabriel Genellina
Sent: Thursday,...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
| |