|
TCHAR lpstrFileName[256] = "";
OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof(ofn));
ofn.IStructSize = sizeof (OPENFILENAME);
ofn.hwndOwner = this->m_hWnd;
ofn.lpstrFileter = "Txt(*.txt;)\o *.txt\o";
ofn.nMaxFile = 256;
ofn.lpstrFile = lpstrFileName;
if(GetOpenFileName(&ofn))
{
CStdioFile f;
if (!f.Open(ofn.lpstrFile, CFile::modeRead|CFile::typeText))
{return;}
m_edit ="";//m_edit为CEdit的字符串关联变量
CString s("");
long fl = f.GetLength();
while (f.GetPosition() < fl)
{
s = "";
f.ReadString(s);
m_edit += s;
m_edit += "\r\n";
UpdateData(FALSE);
}
} |
|