见这段MSDN说明: Text mode provides special processing for carriage return–linefeed pairs. When you write a newline character (0x0A) to a text-mode CStdioFile object, the byte pair (0x0A, 0x0D) is sent to the file. When you read, the byte pair (0x0A, 0x0D) is translated to a single 0x0A byte.即是: 在读的模式下,把换行和回车转换为单个'\r'回车,所以你显示不出来换行。 解决: CString strAll; CFile file("d:\\text.txt",CFile::modeRead | CFile::typeText); char BUF[10000]; UINT length=file.Read(BUF,10000); strAll.Format("%s",BUF); this->SetWindowText(strAll);
Text mode provides special processing for carriage return–linefeed pairs. When you write a newline character (0x0A) to a text-mode CStdioFile object, the byte pair (0x0A, 0x0D) is sent to the file. When you read, the byte pair (0x0A, 0x0D) is translated to a single 0x0A byte.即是:
在读的模式下,把换行和回车转换为单个'\r'回车,所以你显示不出来换行。
解决:
CString strAll;
CFile file("d:\\text.txt",CFile::modeRead | CFile::typeText);
char BUF[10000];
UINT length=file.Read(BUF,10000);
strAll.Format("%s",BUF);
this->SetWindowText(strAll);