Click here to Skip to main content
15,945,119 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to reduce file size from mb to kb + by C++
i need source code
example
Posted
Comments
Maximilien 12-Nov-12 10:41am    
what file you want to reduce in size ? are you talking about file compression ?
pasztorpisti 12-Nov-12 11:42am    
POSIX: truncate()
Windows: SetEndOfFile()
To find examples use google! :-)
Mohibur Rashid 13-Nov-12 3:37am    
Don't post your comment or question as answer.

That might be even NOT feasible.
Generally speaking, you need a compression library (you might select the proper one depending on the file and other requirements, e.g. should the compression be lossless ?)
Google[^] is your friend.
 
Share this answer
 
1. Compressing. For non compressed content it generally works. You can use zlib.
2. Truncating, deleting, overwriting, rebuilding, cleaning. Not good if file contains important or sensitive information beyond the removing limits, or which can not be rebuilt, or generated from other contents as result of some kind of compilation.
3. shrinking, works for databases. In databases for performance considerations, data instead of real deleting, it is only marked as deleted. And in lots of cases the deleted information is much more than 90% of all the information contained in databases
4. Removing unnecesary and insensitive information from files in the places where you know what you are doing. Over internet sometimes it has much impact on traffic. For instance, removing ending tags, removing blanks and comments in scripts, renaming variables and functions to very short, symbolic names
Each method has lots of descriptions in google
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900