Creating big file on Windows

后端 未结 6 634
情歌与酒
情歌与酒 2020-12-17 10:03

I need to create big relatively big (1-8 GB) files. What is the fastest way to do so on Windows using C or C++ ? I need to create them on the fly and the speed is really a

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-17 10:44

    Well this solution is not bad, but the thing you are looking for is SetFileValidData

    As MSDN sais:

    The SetFileValidData function allows you to avoid filling data with zeros when writing nonsequentially to a file.

    So this always leave disk data as it is, SetFilePointerEx should set all data to zeros, so big allocation takes some time.

提交回复
热议问题