-
October 29th, 2010, 12:53 AM
#1
Error in reading file
Hi all,
I have made a .txt file in a format that it contains data per line i.e. in the format
/*text1*/
/*text2abc*/
And its not defined that how much data it can contain per line.
I am reading this file in a per line format basis using this code
Code:
CStdioFile ptr;
CString str;
int i = 0;
ptr.Open(file_name, CFile::ReadWrite, NULL);
while(ptr.ReadString(str))
{
m_List.InsertItem(i,str);
i++;
}
ptr.Close();
My problem is if a list contains more data(5000 lines or above) its taking a lot of time to read it.
I also know that i can read particular number of bytes from buffer but the problem is how can i know that the line has been completely read or not.
Can anybody please help me in this?
Is there any other way to read thid file.
Thanks in advance
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
-
October 29th, 2010, 12:59 AM
#2
Re: Error in reading file
Is it taking long if the list contains too many elements, or if the file has too many lines?
-
October 29th, 2010, 01:02 AM
#3
Re: Error in reading file
supoose if the file is having 30,000 lines i will read a single line and then add it in list control and every time i read that file it is taking considerate amount of time to read and populate the list.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
-
October 29th, 2010, 01:05 AM
#4
Re: Error in reading file
30,000 lines in a list control? You didn't say "list control", you said only "list". It's a different thing. In this case the proper solution is a virtual list.
http://msdn.microsoft.com/en-us/library/ye4z8x58.aspx
http://www.codeguru.com/cpp/controls...icle.php/c4151
You can find lots of other references too.
-
October 29th, 2010, 02:54 AM
#5
Re: Error in reading file
Originally Posted by vjshankwar
supoose if the file is having 30,000 lines i will read a single line and then add it in list control and every time i read that file it is taking considerate amount of time to read and populate the list.
reading 30000 lines from disk doesn't take that long, inserting them in a listcontrol does.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|