与在Linux系统上快速创建大文件相同, 我想在Windows系统上快速创建一个大文件。大的我想是5gb。内容并不重要。内置命令或短批处理文件将是更可取的,但如果没有其他简单的方法,我将接受应用程序。


当前回答

Use:

/*
Creates an empty file, which can take all of the disk
space. Just specify the desired file size on the
command line.
*/

#include <windows.h>
#include <stdlib.h>

int main (int argc, char* ARGV[])
{
    int size;
    size = atoi(ARGV[1]);
    const char* full = "fulldisk.dsk";
    HANDLE hf = CreateFile(full,
                           GENERIC_WRITE,
                           0,
                           0,
                           CREATE_ALWAYS,
                           0,
                           0);
    SetFilePointer(hf, size, 0, FILE_BEGIN);
    SetEndOfFile(hf);
    CloseHandle(hf);
    return 0;
}

其他回答

打开Windows任务管理器,右键单击正在运行的最大进程,然后单击“创建转储文件”。

这将在临时文件夹中创建一个相对于内存中进程大小的文件。

您可以轻松地创建一个千兆字节大小的文件。

您可以使用Sysinternals Contig工具。它有一个-n开关,用于创建一个给定大小的新文件。与fsutil不同,它不需要管理特权。

可以使用cat powershell命令。

首先创建一个包含几个字符的简单文本文件。输入的初始字符越多,它变大的速度就越快。调用out。txt。然后在Powershell中:

cat out.txt >> out.txt

等待足够长的时间,使文件足够大。然后按ctrl-c结束它。

Python中的简单回答:如果你需要创建一个大的真正的文本文件,我只是使用了一个简单的while循环,并能够在大约20秒内创建一个5gb的文件。我知道这很粗糙,但已经够快了。

outfile = open("outfile.log", "a+")

def write(outfile):
    outfile.write("hello world hello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello worldhello world"+"\n")
    return

i=0
while i < 1000000:
    write(outfile)
    i += 1
outfile.close()

我找到的最简单的方法是这个免费工具:http://www.mynikko.com/dummy/

创建任意大小的虚拟文件,其中填充了空格或填充了不可压缩的内容(由您选择)。这是一张截图: