假如我要读取的TXT文件内容如下:
123
245435
5343
53435
...
..
如何把他显示在编辑框中呢?我希望他在编辑框中显示的效果也是
123
245435
5343
53435
...
..我知道用ReadString。可是用ReadString它是一行一行的显示,而且是运行一次就显示一行那么如果很多行的话不是要运行很多次ReadString???本人菜鸟一个。。求解答。最好给个例子谢谢大家了
123
245435
5343
53435
...
..
如何把他显示在编辑框中呢?我希望他在编辑框中显示的效果也是
123
245435
5343
53435
...
..我知道用ReadString。可是用ReadString它是一行一行的显示,而且是运行一次就显示一行那么如果很多行的话不是要运行很多次ReadString???本人菜鸟一个。。求解答。最好给个例子谢谢大家了
if( cfile.Open( "test.dat", CFile::modeRead, NULL ) )
{
char pbuf[100];//这里设置足够大就行了
UINT nBytesRead = cfile.Read( pbuf, 100 );
SetDlgItemText(IDC_EDIT1,pbuf);
}
这样就不用重复读取 txt 了
CStdioFile m_readfile;
CString m_strTemp;
m_readfile.Open( "1.txt ",CFile::modeRead);
m_strTemp.Empty();
m_strText.Empty();
while(m_readfile.ReadString(m_strTemp))
{
m_strText+=m_strTemp+ "\n ";
}
SetDlgItemText(IDC_EDIT1,m_strText);
m_readfile.Close();
try
{
CFile file;
file.Open(_T("F:\\11.txt"), CFile::modeRead);
DWORD dwLen = (DWORD)file.GetLength();
char* buf = new char[dwLen+1];
memset(buf, 0, dwLen+1);
file.Read(buf, dwLen);
file.Close();
CString strText(buf);
SetDlgItemText(IDC_EDIT1, strText);
delete[] buf;
}
catch(CFileException* e)
{
e->ReportError();
e->Delete();
}
m_strText+=m_strTemp+ "\n "; 有这个可是为什么它还是不会自动换行?我明明加了"\n"了