What class to use for big strings ?

  • Thread starter Thread starter Gilbert Tordeur
  • Start date Start date
G

Gilbert Tordeur

Hello,

My program is creating pdf files, around 50 - 100 kB each. Today I write
them in text files, then read them back to store into a database. It's
obvious for me that I can save the text file operations by creating a big
string in memory (only append), but it's unclear what class to use : String
StringBuilder, Stream something or ?

My pdf files contain mainly text, but some of them could also contain a jpeg
image.

Thank you for your help,
Gilbert
 
Hello,

My program is creating pdf files, around 50 - 100 kB each. Today I write
them in text files, then read them back to store into a database. It's
obvious for me that I can save the text file operations by creating a big
string in memory (only append), but it's unclear what class to use : String
StringBuilder, Stream something or ?

My pdf files contain mainly text, but some of them could also contain a jpeg
image.

The typical (as far as I am aware) way of storing binary data into a
database is to use a binary reader and a memory stream.
 
If you just need to "store" the string, then String is fine, but if you will
be doing manipulation of the string, then use StringBuilder.

If you want to compact the data, you could write the data out using a
BinaryWriter.
 
Back
Top