读文件,用CFile::Read整块整块读(比如每次100字节),还要有CFileException的
最好成绩把读出的文件格式为("0x%02X"),谢谢~~
最好成绩把读出的文件格式为("0x%02X"),谢谢~~
解决方案 »
- 如何去掉CPropertySheet界面的下方包含“确定,应用,取消”的固定的矩形区域?
- 高分请教:如何可靠、准确的判断出与互联网是否连通?
- 如何定义和释放特定类型的动态二维数组?
- 我的代码哪里错了,为什么连接不了?
- InstallShield 制作安装包的问题。
- 求com技术方面的资料,谢谢!
- 如何把共享别的工程的窗体资源(将一个工程的窗体加到别的工程中,省去设计工夫??
- 数据采集问题,(只能放100分,不够在贴加分
- 我现在在资源里面做好了一个窗体,如果我不想建立类向导,请问我怎样把该窗体显示出来?谢谢
- windows窗口建立问题
- 请问关于CString类
- 小弟初学VC++,初遇迷惑。。。。。。
CFileException exp;
if(file.Open("c:\\data.dat",CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone,&exp) == FALSE)
{
exp.ReportError(MB_OK|MB_ICONERROR);
//也可以用exp.GetErrorMessage()获得错误信息自己处理
return;
}
void *pBuffer = new BYTE[100];
int nRead;
do {
nRead = file.Read(pBuffer,100);
//对pBuffer进行处理
} while(nRead == 100); delete []pBuffer;
pBuffer = NULL;
CString strResult;
CFile file;
if(file.Open(sPath,CFile::modeRead|CFile::typeBinary))
{
BYTE *buf = new BYTE[1024];
UINT nRead; do
{
nRead = file.Read(buf,1024);
if(nRead > 0)
{
char *pTmp = new char[nRead*2+1];
int nIndex = 0;
CString sTmp;
for(UINT i=0; i<nRead; i++)
{
BYTE n1 = buf[i]/16;
BYTE n2 = buf[i]%16; pTmp[nIndex++] = (char)(n1 + (n1<=9? '0':('A'-10)));
pTmp[nIndex++] = (char)(n2 + (n2<=9? '0':('A'-10)));
}
pTmp[nIndex] = '\0';
strResult += pTmp;
delete []pTmp;
}
}while(nRead == 1024);
file.Close(); delete []buf;
}