CFile f;
CString cfileinfo,cfilename;
f.Open(cpath,CFile::modeRead);
int ifilelength;
ifilelength=f.GetLength(); for(int i=0; i<ifilelength;i++)
{
f.Read(buf,1);
cstr+=(CString)buf;
}
m_editFile.SetWindowText(cstr);我是想从文本文件读出内容加入EDIT控件里,这样是可以读出来可是在EDIT显示的时候却是乱码?
不知道是为什么,是不是我的系统的问题,我是用英文系统,还有一个问题就是
CFile 跟FILE 有什么区别吗??? 谢谢
CString cfileinfo,cfilename;
f.Open(cpath,CFile::modeRead);
int ifilelength;
ifilelength=f.GetLength(); for(int i=0; i<ifilelength;i++)
{
f.Read(buf,1);
cstr+=(CString)buf;
}
m_editFile.SetWindowText(cstr);我是想从文本文件读出内容加入EDIT控件里,这样是可以读出来可是在EDIT显示的时候却是乱码?
不知道是为什么,是不是我的系统的问题,我是用英文系统,还有一个问题就是
CFile 跟FILE 有什么区别吗??? 谢谢
if(!file.Open("d:\\aa.txt", CFile::modeRead))
{
AfxMessageBox("can not open file!");
return;
}
CString strLine,str="";
while(file.ReadString(strLine))
{
str += strLine;
}
file.Close();
GetDlgItem(IDC_EDIT1)->SetWindowText(str);或
CFile cfile;
char pbuf[100];
cfile.Open("d:\\aa.txt",CFile::modeRead);
UINT nBytesRead = cfile.Read( pbuf, 100 );
GetDlgItem(IDC_EDIT1)->SetWindowText(pbuf);
=============================================================
class CFile : public CObjectCFile is the base class for Microsoft Foundation file classes. It directly provides unbuffered, binary disk input/output services, and it indirectly supports text files and memory files through its derived classes. CFile works in conjunction with the CArchive class to support serialization of Microsoft Foundation Class objects.