textreader

How to parse a text file?

Basically I need someone to help me or show me the code that will allow me to read a name and a price from a file i have called c1.txt. This is what i already have. TextReader c1 = new StreamReader("c1.txt"); if (cse == "c1") { string compc1; compc1 = c1.ReadLine(); Console.WriteL...

Quotes in tab-delimited file

Hi all, I've got a simple application that opens a tab-delimited text file, and inserts that data into a database. I'm using this CSV reader to read the data: http://www.codeproject.com/KB/database/CsvReader.aspx And it is all working just fine! Now my client has added a new field to the end of the file, which is "ClaimDescription", ...

How can I easily get a TextReader from an XDocument?

Given an XDocument instance, how can I easily get a TextReader that represents that instance? The best I've been able to come up with is something like this (where xml is an XDocument instance): var s = new MemoryStream(); var sw = new StreamWriter(s); xml.Save(sw); sw.Flush(); s.Position = 0; TextReader tr = new StreamReader(s); ...

How to string multiple TextReaders together?

I have 3 TextReaders -- a combination of StreamReaders and StringReaders. Conceptually, the concatenation of them is a single text document. I want to call a method (not under my control) that takes a single TextReader. Is there any built-in or easy way to make a concatenating TextReader from multiple TextReaders? (I could write my o...

How do I count the number of bytes read by TextReader.ReadLine()?

I am parsing a very large file of records (one per line, each of varying length), and I'd like to keep track of the number of bytes I've read in the file so that I may recover in the event of a failure. I wrote the following: using (TextReader myTextReader = CreateTextReader()) { string record = myTextReader.ReadLine(); bytesRe...

C# List or TextReader limit?

Hi, I'm trying to make a dictionary game, and I have a text file with about 100,000 words each on their own line. I have this code: words = new List<Word>(); Console.WriteLine("Please wait, compiling words list..."); TextReader tr = new StreamReader(DICT); string line = tr.ReadLine(); while (line != "" && line != null) { ...

Browse a file from my pc using web application in asp.net

Hi, I have a web application which I uploaded using IIS. I want the users using the application would be able to select a file located on their (the user) computer and read its contents. The code is: TextReader trs = new StreamReader(faFile.Value); DataAccessLayer.clearFA(); string line = trs.ReadLine(); ...

.NET TextReader.Read - Detect EOF with no Peek supported

I've got a class I need to read a data from. It's derived from TextReader (particularly FilterReader from http://www.codeproject.com/KB/cs/IFilter.aspx ). ReadToEnd() hangs when reading large files. ReadLine() doesn't work at all, so the only way to read in chunks is using .Read() function. MSDN suggests using Peek() and check if it retu...