views:

141

answers:

4

Will I run into problems if I write a base64 string into a file without breaking it up using carriage returns?

Is there a length where I'll run into difficulties writing and reading a big string in one go?

Right now the size of the strings I'm storing are about 100 characters but they can get into the 10,000+ range - will that be a problem?

Thanks in advance.

+5  A: 

You can have files as big as your file system allows with no line breaks in them.

Reading them, on the other hand, will be difficult for large files. I recommend a StreamReader or at least a buffer in the form of a byte array instead of trying to load it as a string.

Neil N
+1  A: 

If the application that decodes the data is reading the file line at a time, it may not be the best use of resources. But the only way I can see it causing a problem is if the decoding application reads line at a time, the lines are really long and the decoding application is running low on memory.

R Samuel Klatchko
+1  A: 

To answer your direct question, yes there is a size that you will start to notice read/write performance issues if you are using a single large string; however, it depends on many things, including Disk IO, CPU load, and even free memory. On a semi-modern machine, I'd say you wont really have issues as long as your files are under 2-3 MB.

That said, Neil's advice to use a buffer is good advice, since it will yeild much better performance and allow you to display a progressbar, etc.

Nate Bross
+2  A: 

That entirely depends on the app that reads the file. I certainly wouldn't do this if it is a native C/C++ app that reads it. A .NET or Java app shouldn't have any trouble with it, short from consuming more memory. MIME (RFC 2045) requires no more than 76 characters on a line and "=" for padding. I'd suggest you use that.

Hans Passant