几何尺寸与公差论坛

 找回密码
 注册
查看: 2261|回复: 1

读取txt文本文件

[复制链接]
发表于 2006-12-23 15:24:44 | 显示全部楼层 |阅读模式
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);
}
}
 楼主| 发表于 2006-12-23 15:25:35 | 显示全部楼层

回复: 读取txt文本文件

编程环境vc6.0
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-12-22 17:39 , Processed in 0.034628 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表