Shrinking a file

Hi,

I have a long file, and I want to make it smaller. How can I do it



Answer this question

Shrinking a file

  • 4Runner

    .net 2.0 has ZIP libraries built in...

  • Kamii47

    If you want to create your own compression algorithm from existing one, search for Lossless data compression, http://en.wikipedia.org/wiki/Lossless_data_compression. You'll find lot's of topic and lot's of document to read.

  • Shirvo

    I guess then you really don't want to hear a recommendation to dump the flatfile format for XML stored in a SQL Server DB then do you I do hope you're putting all your mutable data under the "Documents and Setttings" tree NOT in the application directory :)

  • ragc

    Because, for example, I have more than 10000 messages, each is like 200 bytes, so all of them are like 2000000 bytes = 2MB. This is without the attachments, and the long messages, which could be almost 1KB..

    and if I have a lot of identities on the comp, it will take a lot of storage which could be used for other things.


  • mranzani

    2mb That's nothing. I guess it depends on the target computers, but most modern computers have hard drives of 40gb or more. Ultimately you will need to rely on users deleting what they don't want to keep.

    Alternatively offer an "archive" function like Outlook does, and soon as they use that option it ZIPs up all the files.



  • hendrikswa

    I don't want to use winzip and Unzip the fule every time I need it.. I need the files very often, and it can take some time to unzip more than 5000 files one after the other, use them, and re-zip them...

    Any other ways


  • vahdam_mn

    I forgot that the full framwork has compression built in, I'm used to working with devices. These have vast resources of ram and hard disk, so obviously no-one would want to compress data on that platform so MS left compression out of the compact framework.
    *sarky mode off*

    I agree with weird bear, I'd not worry about compression unless I was using 100x more than you are talking about

  • pstader

    What exactly is it you want to do then You need supply full and accurate details on what you need to do.

  • B.Huard

    There are a couple of options. You could strip out all the unwanted stuff like the message headers and whatever. Alternatively, storing the file in a different format than plain-text/rich-text/ASCII might work. You could possibly store as hex or similar. Might work.

    Why is the size of the file so important



  • IanO

    The .net framework does have compression classes

    System.io.Compression.

    http://msdn2.microsoft.com/en-us/library/system.io.compression.compressionmode.aspx

    The following thread has an example
    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=424050&SiteID=1

    This may further help as the compression is pretty quick.


  • mark aoki

    Ok..

    I'm making an Email client program.

    Currently I save every message on a different file, because If I save all of the messages in the same file, it's bigger (because I need to write seperators between the messages).

    So.. I need a way to shrink every message file, to make the "mailbox" smaller.


  • Dietz

    zip it
    http://www.winzip.com/

    if you mean in code with API, then
    http://www.sharpziplib.com/
    else shell to a command line
    or http://www.7-zip.org/
    endif

  • jayaraja

    ok, thanks.
  • Shrinking a file