Hi I would like to open a text file and display it's contents in a View? I can get to the stage where i get the path of the file I'd like to open then what?
Thanks in advance
Printable View
Hi I would like to open a text file and display it's contents in a View? I can get to the stage where i get the path of the file I'd like to open then what?
Thanks in advance
Get the reference help of:
Serialize();
CArchive class
try ReadString() of it and then pDC->TextOut()
or use the overloaded << and >>
In general read the related help about the above
and you will manage with this hard problem! :)
You should use the CEditView, not the CView.
After that,just do it as following:
CStdioFile stdfile(filename,CFile::modeRead);
CString str1="";
CString str2="\r\n";
while(stdfile.ReadString(str1))
str2+=str1+"\r\n";
YourView->GetEditCtrl()->SetWindowText(str2);
Try it,hope it works.