用TFileStream怎么完成对二进制文件的读取?
char Buff[4096];
int iBytesRead;
int FileLeng;
char *pszBuffer;
String *dest;
AnsiString BitFilePath=ExtractFilePath(ParamStr(0))+ "SoftVer.out ";
TFileStream *BitStream=new TFileStream(BitFilePath,fmOpenRead);
FileLeng=BitStream-> Seek(0,soFromEnd);
pszBuffer =new char[FileLeng+1];
iBytesRead=BitStream-> Read(pszBuffer,FileLeng);
strcpy(Buff,pszBuffer);
我这样做有问题吗?怎么能显示出二进制文件的内容?
[解决办法]
strcpy遇到\0就结束了,因此必须用memcpy拷贝:
iBytesRead=BitStream-> Read(pszBuffer,FileLeng);
memcpy(Buff,pszBuffer,iBytesRead);
[解决办法]
内容就是那么读的,显示要看你的内容是什么