如何在创建一个文件的时候,就可以使其具有很大的长度

linvoc 2001-09-12 10:29:29
我要做一个象类似网络蚂蚁那样的程序,在一开始下载的时候就创建了与源文件大小相同的文件,这一点如何实现?请有知者告知。是否用CreateFileMapping来实现,我第一次使用成功,但第二次做就不能实现了。
...全文
147 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
linvoc 2001-09-12
  • 打赏
  • 举报
回复
有没有相关源码啊,用SetFilePointer()和SetEndOfFile()
regit 2001-09-12
  • 打赏
  • 举报
回复
first SetFilePointer( )
then SetEndOfFile( )
Note that it is not an error to set the file pointer to a position beyond the end of the file. The size of the file does not increase until you call the SetEndOfFile, WriteFile, or WriteFileEx function. A write operation increases the size of the file to the file pointer position plus the size of the buffer written, leaving the intervening bytes uninitialized.

linvoc 2001-09-12
  • 打赏
  • 举报
回复
SetLength()的参数是DWLOAD,但是我的视频文件可能有4,5G的,那就不能用了。
蒋晟 2001-09-12
  • 打赏
  • 举报
回复
CFile::SetLength
virtual void SetLength( DWORD dwNewLen );
throw( CFileException );

Parameters

dwNewLen

Desired length of the file in bytes. This value can be larger or smaller than the current length of the file. The file will be extended or truncated as appropriate.

Remarks

Call this function to change the length of the file.

Note With CMemFile, this function could throw a CMemoryException object.
linvoc 2001-09-12
  • 打赏
  • 举报
回复
大家不要忙着回答美国被炸或其他MM的问题吧,这个问题才有点意思,赶快回答回答,谢谢啦!!!
linvoc 2001-09-12
  • 打赏
  • 举报
回复
快点告诉我吧,做不出来要死了。
linvoc 2001-09-12
  • 打赏
  • 举报
回复
或者可以采用其他的方法来填充文件。注意,我的文件都是大视频文件,有的有4,5G

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧