vc CFile::Read 的问题
CFile file;
if(file.Open(_T("E:\\test\\test.txt"),CFile::readOnly))
{
m_length = file.GetLength();
//byte *pBuffer = new byte[m_length];
char buffer[1024];
memset(buffer,0,1024);
try
{
file.Read(buffer,1024);
}
catch (CFileException* e)
{
CString error;
e->GetErrorMessage(error.GetBuffer(),1024);
m_result = error;
}
UpdateData(FALSE);
}
在文件读取时,catch到错误,错误码为:"对 E:\test\test.txt 的访问被拒绝。"
各位大侠,是什么原因啊?
[解决办法]
CFile::readOnly
改为
CFile::modeRead 试试