Error Cannot Read From A Closed Textreader
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About cannot read from a closed textreader file readlines Us Learn more about Stack Overflow the company Business Learn more about hiring developers cannot read from a closed textreader streamreader or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack cannot read from a closed textreader in c# Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Cannot read from a closed TextReader up
Csvhelper Cannot Read From A Closed Textreader
vote 0 down vote favorite I've got a system that processes some large CSV files. The scenario has now arisen where these files might have a number of none-delimited, worthless lines preceding the actual comma-delimited content. The approach I have taken is to create a temporary reader to ascertain the number of superfluous lines and then move the working TextReader on that number of lines ready to be processed. My code is as follows: private static TextReader PrepareReader(TextReader reader) { // Variables TextReader tmpReader = reader; Int32 superfluousLineCount = 0; // Determine how many useless lines we have using (tmpReader) { string line; string headerIdentifier = "&1,"; while ((line = tmpReader.ReadLine()) != null) { // Check if the line starts with the header row identifier if (line.Substring(0, 3) != headerIdentifier) { // Increment the superfluous line counter superfluousLineCount++; } else { break; } } } // Move the source reader through how many lines we want to ignore using (reader) { for (int i = superfluousLineCount; i > 0; i--) { reader.ReadLine(); } } // Return return reader; } However, the reader.ReadLine(); in this part of the code: for (int i = superfluousLineCount; i > 0; i--) { reader.ReadLine(); } ...throws the following exception Cannot read from a closed TextReader. ObjectDisposedException in mscorlib Method: Void ReaderClosed() Stack Trace: at System.IO.__Error.ReaderClosed() at System.IO.StreamReader.ReadLine() at CsvReader.PrepareReader(TextReader reader) in CsvReader.cs:line 93 Any advice greatly appreciated. Also, is the best way to go about my challenge? Notes: Framework 2.0 Thanks. c# .net-2.0 share|improve this question asked Jun 14 '12 at 15:03 Ste 875927 add a comment| 2 Answers
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Cannot read from http://stackoverflow.com/questions/11035977/cannot-read-from-a-closed-textreader a closed textreader after iterating through IEnumerable once up vote 0 down vote favorite I've got a problem with "Cannot read from a closed textreader" exception. I have a program which is supposed to get data from file, then do some funny stuff with it and get timespans of everything. First in one function, I'm loading the data: IEnumerable
Wiki Downloads Donate Advanced Search Forum RocketLauncher General Discussion RocketLauncherUI [SOLVED] error : Cannot read from a closed text reader If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have http://www.rlauncher.com/forum/showthread.php?970-error-Cannot-read-from-a-closed-text-reader to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Thanks: 3 Post #11991 (3) Thread: error : Cannot read from a closed text reader Page 1 of 2 12 Last Jump to page: Results 1 to 20 of 33 Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Search Thread Advanced Search Display cannot read Linear Mode Switch to Hybrid Mode Switch to Threaded Mode [SOLVED] error : Cannot read from a closed text reader #1 malcom1970 View Profile View Forum Posts Private Message View Blog Entries View Articles Instant PM Junior Member Join Date Apr 2015 Posts 1 Total Downloaded 0 Downloads6 Uploads0 Contribute If you enjoy reading the content here, click the below image to support our site. 05-05-201506:48 AM Hi all, i have installed a clean install of rlauncher cannot read from but when i want to update from rocketlauncherui i receive this error : cannot read from a closed text reader. Have you an idea to solve this ? Thanks in advance, Malcom ADDED : i tried the transistion tools, all is working fine except when i tried to update from rocketlauncherui The .NET 4.5.2 updates solved my issue Last edited by malcom1970 ; 05-07-2015 at 02:29 PM. Reason: [SOLVED] Send PM Re: error : Cannot read from a closed text reader #2 silverfox0786 View Profile View Forum Posts Private Message View Blog Entries View Articles Instant PM Member Join Date Mar 2015 Posts 45 Total Downloaded 335.7 KB Downloads10 Uploads0 05-05-201512:45 PM im having same issue Send PM Re: error : Cannot read from a closed text reader #3 32assassin View Profile View Forum Posts Private Message View Blog Entries View Articles Instant PM Junior Member Join Date Nov 2014 Posts 17 Total Downloaded 0 Downloads11 Uploads0 05-05-201503:28 PM I had the same error, upgraded Microsoft .NET Framework from 4.0 to 4.5.2 and it fixed my problem Send PM Re: error : Cannot read from a closed text reader #4 silverfox0786 View Profile View Forum Posts Private Message View Blog Entries View Articles Instant PM Member Join Date Mar 2015 Posts 45 Total Downloaded 335.7 KB Downloads10 Uploads0 05-05-201503:53 PM that is ext