CString TempString,TextString;
CStdioFile File;
char szFileFilter[]=
"Text files(*.txt)|*.txt|"
"Source files(*.c)|*.c|"
"Source files(*.asm)|*.asm|"
"All files(*.*)|*.*||";
CFileDialog FileDlg(TRUE,"","",
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST,
szFileFilter,this);
FileDlg.m_ofn.lpstrTitle=_T("打开");
if(FileDlg.DoModal()==IDOK)
{
if(!File.Open(FileDlg.GetFileName(),CFile::modeRead|CFile::typeText))
{
MessageBox("打开文件操作失败","信息提示",MB_OK);
return;
}
else
{
TempString.Empty();
SetWindowText(TempString);
while(File.ReadString(TempString))
{
TextString+=TempString;
TextString+="\r\n";
}
SetWindowText(TextString);
}
}