首页
社区
课程
招聘
[求助]请教一个MFC的CFile问题
发表于: 2005-8-5 17:39 6608

[求助]请教一个MFC的CFile问题

2005-8-5 17:39
6608
请问用CFile类怎样去
改写一个大的二进制文件里的一个字节数据呢?
谢谢!

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

收藏
免费 0
支持
分享
最新回复 (3)
雪    币: 217
活跃值: (99)
能力值: ( LV4,RANK:50 )
在线值:
发帖
回帖
粉丝
2
BOOL Open( LPCTSTR lpszFileName, UINT nOpenFlags, CFileException* pError = NULL );//打开文件
Parameters
lpszFileName
A string that is the path to the desired file. The path can be relative, absolute, or a network name (UNC).
nOpenFlags
A UINT that defines the file’s sharing and access mode. It specifies the action to take when opening the file. You can combine options by using the bitwise-OR ( | ) operator. One access permission and one share option are required; the modeCreate and modeNoInherit modes are optional. See the CFile constructor for a list of mode options.
pError
A pointer to an existing file-exception object that will receive the status of a failed operation.

LONG CFile::Seek( LONG lOff, UINT nFrom );//设置指针位置
Parameters
lOff
Number of bytes to move the pointer.
nFrom
Pointer movement mode.  Must be one of the following values:
CFile::begin   Move the file pointer lOff bytes forward from the beginning of the file.
CFile::current   Move the file pointer lOff bytes from the current position in the file.
CFile::end   Move the file pointer lOff bytes from the end of the file. Note that lOff must be negative to seek into the existing file; positive values will seek past the end of the file.

void CFile::Write( const void* lpBuf, UINT nCount );//写数据
Parameters
lpBuf
A pointer to the user-supplied buffer that contains the data to be written to the file.
nCount
The number of bytes to be transferred from the buffer. For text-mode files, carriage return?linefeed pairs are counted as single characters.
2005-8-5 21:01
0
雪    币: 214
活跃值: (70)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
3
谢谢楼上朋友,
如果我用::Seek()设置指针位置到文件的中间,
用Write()写数据时是插入的?还是改写的?
2005-8-6 03:31
0
雪    币: 217
活跃值: (99)
能力值: ( LV4,RANK:50 )
在线值:
发帖
回帖
粉丝
4
最初由 fengercn 发布
谢谢楼上朋友,
如果我用::Seek()设置指针位置到文件的中间,
用Write()写数据时是插入的?还是改写的?


是改写,想插入就比较麻烦了.
2005-8-6 11:38
0
游客
登录 | 注册 方可回帖
返回
//