How to Generate File of a determinate Size in Windows?

依然范特西╮ 提交于 2021-02-04 03:14:29

问题


How is the Best and fastest way to do it?


回答1:


PowerShell:

$f = new-object System.IO.FileStream c:\temp\test.dat, Create, ReadWrite
$f.SetLength(42MB)
$f.Close()

This will create a file c:\temp\test.dat that consists of 42MB of nullbytes. You can of course just give byte count instead as well. (42MB = 42 * 1048576 for PowerShell)




回答2:


I found this Page, I try it and work great.

To create a single File use

fsutil file createnew filename filesize

To create a lot of Files use

For /L %i in (1,1,25000) do fsutil file createnew A%i.tmp 12288

will create 25,000 files of 12288 bytes (12KB) named A1.tmp, A2.tmp, A3,tmp…




回答3:


c:\>fsutil file createnew /?
Usage : fsutil file createnew <filename> <length>
   Eg : fsutil file createnew C:\testfile.txt 1000


来源:https://stackoverflow.com/questions/808005/how-to-generate-file-of-a-determinate-size-in-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!