Click here to Skip to main content
15,891,981 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
20/08/2012-17.30.45
is displayed and rest data is lost.

kindly help me how to solve this problem?

Thanks in advance....
Posted
Updated 20-Aug-12 2:20am
v2
Comments
Malli_S 20-Aug-12 8:23am    
Please show up the code you have written.
[no name] 20-Aug-12 9:30am    
You really expect someone to fix your code without actually showing the code to them?
Fresher16 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";
}

fp.Close();

m_EditBox.SetWindowText(m_Buffer);
Rishika Singh 15-May-20 6:10am    
Hey Can you tell me what is cFileAddr?

1 solution

See the process of reading a text file from here..
http://support.microsoft.com/kb/307398[^]
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..
 
Share this answer
 
Comments
ridoy 21-Aug-12 3:04am    
Seems your code is good..do you have any problem yet?
Fresher16 21-Aug-12 6:20am    
i have mentioned my problem above... i missing some data...
Fresher16 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900