Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

i'm not lazy i'm just resting before i get tired.
  • *Experts*
Posted
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.
Posted
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
i'm not lazy i'm just resting before i get tired.
  • *Experts*
Posted
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.
Posted
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?
i'm not lazy i'm just resting before i get tired.
  • *Experts*
Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...