首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

vc CFile:Read 的有关问题

2012-04-09 
vc CFile::Read 的问题CFile fileif(file.Open(_T(E:\\test\\test.txt),CFile::readOnly)){m_length

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 试试

热点排行