Saving a File - a question

  • Thread starter Thread starter garyusenet
  • Start date Start date
G

garyusenet

Hi all,

at the moment i'm saving a treeview and all its nodes by serialising it
and storing it in a file.
I recently openeing the file which had quite a lot of plain text in it
and noticed that certain phrases repeated themselves throughout the
file many, many times. These phrases seemed to reference properties in
the treeview - which is of course what I expected.

Is there any way I can write the file so that common phrases are
replaced with 'tokens' (probabally the wrong word). And these tokens
are defined at the start of the file.

The reason for this is that I think it would save so much space in the
file.

I'm sure there's a simple explanation for this, but am new to system.IO
- so please be patient!

Thanks,

Gary.
 
That's exacly how zip works - why don't you zip the file?

http://msdn.microsoft.com/msdnmag/issues/03/06/ZipCompression/
http://www.example-code.com/csharp/csCreateZipFile.asp
http://www.gold-software.com/download3321.html

But before you do this - is the file size really a problem? You could
be wasting your time optimising something that doesn't need optimising,
particularly if there's only one file per user. Remember, this will
also slow your application down (very slightly) as it will have to zip
and unzip the file.

Josh
http://www.thejoyofcode.com/
 
Back
Top