|
Great! I know it seems weird that I would be excited, but as long as I understand what is going on under the hood, I can work around it.
That is a huge help. So I have to specify which files will be compressed and which wont, Oh Well.
if i didnt like to code, i wouldnt do this for a living
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
Assuming the compression is not expensive (e.g. you are only working with small streams), then you could simply code the method such that it tries to compress the data. Then it would compare the original size to the compressed size and if the compressed size is larger, then it saves the original data and trashes the compressed data. You would probably need to maintain a flag with the file that specifies whether you compressed it though.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
I have a pretty good idea of which filetypes are compressed or not, so i will probably integrate what you suggested with an enum or something that will look at the extension. The code i am writing will possible handle hundreds of files at a time, and any memory overhead i can save will be good.
Thanks again for your help, you have saved me a headache.
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
This is fairly typical. Once a file has been compressed, compressing it again very rarely makes it smaller still. As Tom pointed out, the second compression adds additional header information to the file, which ends up making it bigger. There really isn't a way around this.
|
|
|
|
|
Hi,
the best way to compress a collection of files is to turn them over all at once to one of the
popular compression utilities such as WinZip. You will then again notice that some files
don't get extra compression (such as ZIP files!), but the overhead will be minimal and mostly
shared.
The command line interface to WinZip requires a separate install, once installed you can
call it using Process.Start().
There also are Zip libraries available (such as ZLIB), search the CodeProject articles.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Great suggestion, however, the issue i have is that each file is to be saved to a database, and each file has to be its own seperate entity. The other thing is that i cant have the user installing a seperate utility, it needs to be all in one package.
I already have an interface in the works for saving the files, so modifying the code for "non-compressable" formats should be a cinch.
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
OK.
One way for predicting compressability is by performing a simple statistical analysis:
take part of the file (say the first 1KB) and make a histogram on the byte values.
If the histogram is very flat, chances are compression wont buy you anything;
if a lot of byte values occur very (in)frequently, compression should work well.
One measure could be:
int infrequent=number of values occuring less than samplesize/512;
int frequent=number of values occuring more than samplesize/128;
bool compression_will_work=infrequent+frequent>64;
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Food for thought. If nothing else, it will give me something to play with ]
thanks again!
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
here i am using asp.net
how we can search the data in directories
with regards
sunil
|
|
|
|
|
sunilwise wrote: how we can search the data in directories
do you mean how do you get the physical path to a directory? or what kind of data?
Do your best to be the best
|
|
|
|
|
hi ...
i want to save my program setting in a xml file.
i create most of things for create, read, write but i don't know how can update a node value in xml with C#.
can you help me?
thanks.
|
|
|
|
|
Here you have a sample in C#
http://eai.ittoolbox.com/groups/technical-functional/xml-l/update-xml-element-value-using-cnet-1328886
Visit my blog at http://dotnetforeveryone.blogspot.com/
|
|
|
|
|
hi "il_masacratore"
thanks so much.
i visited your reference. it was good.
and i visit your blog. unfortunately i can not your blog (because language).
and then click "Create Blog" link on top - right corner. then go to create blog page and show my google id and name. it was so interest for me .
is it use of google information?
if yes, do you know how can use of such google information ?
|
|
|
|
|
in my search , found follow link that think is very good for beginners XML.
http://www.google.com/url?sa=t&ct=res&cd=1&url=http%3A%2F%2Fwww.codeproject.com%2Fsoap%2FXmlHelper.asp&ei=228BR6zIKp2MeqP0nOUC&usg=AFQjCNFZG4M2LEqCk5J-QpMH73WjSxSE_w&sig2=zk0Ml3YxmDchiDyTVtD46Q
|
|
|
|
|
i have done a simple login page web application. which is working perfectly but now i want to add change password option for the user after logging in into the page.
I have encrypted the password and stored in the database. the datatype i have given for password is binary, i am using stored procedures. For converting the binary value password i have used casting and converting keywords in sql server 2000
can any one help me to write the code for changing password option .
|
|
|
|
|
sunilwise wrote: can any one help me to write the code for changing password option
How much different can it be from the code that initially sets the password? Surely it just changing the INSERT into an UPDATE? (more-or-less)
|
|
|
|
|
hi. guys kool .
How can i make a self excutable file in console or windows application in c sharp.
thanks to all that help me
so much of happy ending...
|
|
|
|
|
What do you mean?
The result of compiling a Console or Windows project is an executable file.
Paul Marfleet
|
|
|
|
|
I have mentioned "Self excutable file"
which mean it should run automatically on a certain situation without clicking the icon.
so much of happy ending...
|
|
|
|
|
What situation? You haven't explained what you are trying to do.
If you want to launch an executable programmatically, have a look at the Process[^] class.
Paul Marfleet
|
|
|
|
|
yeah thats right.
The file should run automatically if we send it to another location, it maybe a folder or a computer.
thanks
so much of happy ending...
|
|
|
|
|
zafax4 wrote: The file should run automatically if we send it to another location, it maybe a folder or a computer.
Hmm, that sounds a bit dodgy...
You're not trying to write a virus, are you?
Paul Marfleet
|
|
|
|
|
ya you are right.
im creating a keyloger.
its a hacking style tool.
job: when i attach to a mail, it should runs when user opens their mail.
thanks.
so much of happy ending...
|
|
|
|
|
|
so much of happy ending...
|
|
|
|