bpayne111 Posted October 20, 2003 Posted October 20, 2003 I am aware that a StreamReader won't work for reading text files with large amounts of data. So what do i use instead? I need to input from various sized files into a database, sometimes the files may be very large. I CAN assume that the files will be no larger than a file in notepad though, for the data i'm reading always comes from notepad. thanks brandon Quote i'm not lazy i'm just resting before i get tired.
*Experts* Volte Posted October 20, 2003 *Experts* Posted October 20, 2003 Instead of using ReadToEnd, you can just use the Read method in a loop to read the file chunk by chunk. There should be no limit imposed on you there. Quote
bpayne111 Posted October 20, 2003 Author Posted October 20, 2003 that sounds perfect... so it'll work as long as i do it line by line? (i could have sworn i had trouble with this before on another project Quote i'm not lazy i'm just resting before i get tired.
*Experts* Volte Posted October 20, 2003 *Experts* Posted October 20, 2003 If you want to read line by line, you use ReadLine. Read reads in chunks, not lines, meaning it will read a certain number of characters over and over until it reaches the end. There is an example or two in the MSDN. Quote
bpayne111 Posted October 20, 2003 Author Posted October 20, 2003 I know how to use them... but i thought they had limits as too how large of files they could use. Can a notepad file be bigger than a SreamReaders buffer? Quote i'm not lazy i'm just resting before i get tired.
*Experts* Volte Posted October 20, 2003 *Experts* Posted October 20, 2003 A NotePad file? You mean a TextFile? TextFiles are just files containing text with no special formatting. They can be any size. StreamReaders' buffer only really matter when reading a whole file, since it needs to buffer the whole file first. When reading in chunks, it doesn't matter. Quote
bpayne111 Posted October 20, 2003 Author Posted October 20, 2003 ohhh ok maybe that's the problem i had thanks man Quote i'm not lazy i'm just resting before i get tired.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.