在MFC中,我想读取一个unicode编码的txt文件,一行一行的读取,然后把每行读出来的值放在string中。哪位哥们能给个实例啊?谢谢啦
解决方案 »
- GDI+加载png图片可以用画刷吗?
- 如何使对话框的一部分控件不发生重绘?
- WTL(比如金山开源的那个)制作的界面可以调用Dll 和lib吗
- COM编程、驱动编程、P2P编程
- 关于RichEditCtrl的两个问题
- 有用VC.NET做项目的吗? 学VC.NET有什么用?
- 请问关于MFC程序设计结构的问题
- HANDLE和HINSTANCE有什么区别?
- VC++中两个不同的头文件中定义了相同的类型
- typedef CArray<CString,CString> intArray; CArray<intArray,intArray> aaa2;这样定义2维数组对吗?
- ListCtrl的表头总是有个边儿,怎么回事
- 这个功能是怎么实现的?
wfstream sk;
sk.open(m_fName,fstream::in|fstream::out);
while(getline(sk,strline))
{
string s = (char *)_bstr_t(strline.c_str() );
}
这样读出来放在s里,数据不对啊,是??:,而里面实际是:LOG啊
{
CStdioFile stdFile;
if(!stdFile.Open(L"d:\\20100823.log", CFile::modeRead | CFile::typeBinary))
{
AfxMessageBox(L"打开文件错误");
return;
}
CString strLine;
while(stdFile.ReadString(strLine))
{
AfxMessageBox(strLine);
}
stdFile.Close();
}
CString suu=L"C:\\32.log";
if(!stdFile.Open(suu, CFile::modeRead | CFile::typeBinary))
{
MessageBox("打开文件错误");
return;
}
CString strLine=L"";
while(stdFile.ReadString(strLine))
{
AfxMessageBox(strLine);
}
stdFile.Close();我用的VC6.还是不行啊
try
{
CFile file;
file.Open(_T("F:\\11.txt"), CFile::modeRead);
DWORD len = file.GetLength();
WCHAR* pBuf = new WCHAR[len+1];
memset(pBuf, 0, sizeof(WCHAR)*(len+1));
file.Seek(2, CFile::begin);
file.Read(pBuf, len);
file.Close(); AfxMessageBox(CString(pBuf)); delete[] pBuf;
pBuf = NULL;
}
catch (CFileException* e)
{
e->ReportError();
e->Delete();
}