Click here to Skip to main content
13,300,331 members (50,652 online)
Rate this:
Please Sign up or sign in to vote.
See more:
how to reduce file size from mb to kb + by C++
i need source code
Posted 12-Nov-12 1:51am
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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171207.1 | Last Updated 13 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100