Click here to Skip to main content
11,925,896 members (61,298 online)
Rate this:
Please Sign up or sign in to vote.
See more: MFC VisualC++
Hello everyone, I am new to Visual C++, MFC.
What i m trying to do is, Read the text file data and display the same in a Read Only, Multiline Edit Box without using open Dialog box. The length of file is variable.I am able to display the text file data in an edit box but i m using CTime class to get the time when the event takes place and writing the same in Text file but while reading m only able to read the time and the data in front of time is missing. can anyone pls help me with the same?

For Example:- 20/08/2012 - 17.30.45 Initializing LED test....

so when i start reading and displaying the same in an edit box, only
is displayed and rest data is lost.

kindly help me how to solve this problem?

Thanks in advance....
Posted 20-Aug-12 3:16am
Edited 20-Aug-12 3:20am
Malli_S 20-Aug-12 8:23am
Please show up the code you have written.
Wes Aday 20-Aug-12 9:30am
You really expect someone to fix your code without actually showing the code to them?
Anurag Kela 21-Aug-12 2:31am
Here is the code....

CStdioFile fp;
CString m_Buffer;
CString m_TempBuffer;

fp.Open(cFileAddr, CFile::modeRead);

while (!feof (fp.m_pStream))
fp.ReadString( m_TempBuffer );
m_Buffer += m_TempBuffer;
m_Buffer += "\r\n";



1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

See the process of reading a text file from here..[^]
After that while displaying data you need some string operation over that..It's up to you man,you can't expect whole of your code from here.So try it yourself,then tell us what problem you are facing..
ridoy 21-Aug-12 3:04am
Seems your code is you have any problem yet?
Anurag Kela 21-Aug-12 6:20am
i have mentioned my problem above... i missing some data...
Anurag Kela 21-Aug-12 6:21am
And for writing the Date, Time and Data to a text file i m doing it in following manner.....

CString strDate, strTime;

Time = CTime::GetCurrentTime();
strDate = Time.Format("%x-");
strTime = Time.Format("%X");

file.Write(strDate, 9);
file.Write(strTime, 9);
file.Write(" Initializing Key Test....\r\n", 28);
ridoy 21-Aug-12 6:36am
Ok,then from that text of file you can use SubString method to cut your necessary text if the text length of your necessary text is same for all cases in a text file.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.151126.1 | Last Updated 20 Aug 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100