与在Linux系统上快速创建大文件相同, 我想在Windows系统上快速创建一个大文件。大的我想是5gb。内容并不重要。内置命令或短批处理文件将是更可取的,但如果没有其他简单的方法,我将接受应用程序。
当前回答
打开Windows任务管理器,右键单击正在运行的最大进程,然后单击“创建转储文件”。
这将在临时文件夹中创建一个相对于内存中进程大小的文件。
您可以轻松地创建一个千兆字节大小的文件。
其他回答
临时文件应该存储在Windows临时文件夹中。根据Rod的回答,您可以使用下面的一行代码创建一个5 GB的临时文件,该文件返回文件名
[System.IO.Path]::GetTempFileName() | % { [System.IO.File]::Create($_).SetLength(5gb).Close;$_ } | ? { $_ }
解释:
[System.IO.Path]::GetTempFileName() generates a random filename with random extension in the Windows Temp Folder The Pipeline is used to pass the name to [System.IO.File]::Create($_) which creates the file The file name is set to the newly created file with .SetLength(5gb). I was a bit surprised to discover, that PowerShell supports Byte Conversion, which is really helpful. The file handle needs to be closed with .close to allow other applications to access it With ;$_ the filename is returned and with | ? { $_ } it is ensured that only the filename is returned and not the empty string returned by [System.IO.File]::Create($_)
我需要一个普通的10gb文件进行测试,所以我不能使用fsutil,因为它创建稀疏文件(感谢@ZXX)。
@echo off
:: Create file with 2 bytes
echo.>file-big.txt
:: Expand to 1 KB
for /L %%i in (1, 1, 9) do type file-big.txt>>file-big.txt
:: Expand to 1 MB
for /L %%i in (1, 1, 10) do type file-big.txt>>file-big.txt
:: Expand to 1 GB
for /L %%i in (1, 1, 10) do type file-big.txt>>file-big.txt
:: Expand to 4 GB
del file-4gb.txt
for /L %%i in (1, 1, 4) do type file-big.txt>>file-4gb.txt
del file-big.txt
我想创建一个10gb的文件,但出于某种原因,它只显示为4gb,所以我想安全起见,停止在4gb。如果您真的想确保您的文件能够被操作系统和其他应用程序正确处理,请停止将其扩展到1gb。
我在http://www.scribd.com/doc/445750/Create-a-Huge-File上找到了一个使用DEBUG的解决方案,但我不知道一个简单的方法来编写它,它似乎不能创建大于1gb的文件。
另一个GUI解决方案:WinHex。
“File” > “New” > “Desired file size” = [X]
“File” > “Save as” = [Name]
与一些已经提出的解决方案相反,它实际上是在设备上写入(空)数据。
它还允许用可选择的模式或随机数据填充新文件:
“Edit” > “Fill file” (or “Fill block” if a block is selected)
快速执行还是在键盘上快速输入?如果你在Windows上使用Python,你可以尝试这样做:
cmd /k py -3 -c "with open(r'C:\Users\LRiffel\BigFile.bin', 'wb') as file: file.truncate(5 * 1 << 30)"
推荐文章
- 我如何找到哪个程序正在使用端口80在Windows?
- 在Windows中有像GREP这样的模式匹配实用程序吗?
- 如何在Windows命令提示符下运行.sh ?
- 如何从命令行在windows中找到mysql数据目录
- 在没有事件源注册的情况下写入Windows应用程序事件日志
- Windows FINDSTR命令的未记录的特性和限制是什么?
- 无法在Windows上从/usr/local/ssl/openssl.cnf加载配置信息
- 用Windows任务调度器运行批处理文件
- GIT克隆在windows中跨本地文件系统回购
- 如何运行一个PowerShell脚本而不显示窗口?
- PowerShell:仅为单个命令设置环境变量
- 为什么这个Windows批处理文件只执行第一行,而在命令shell中执行所有三行?
- 如何将文件内容读入批处理文件中的变量?
- 环境变量存储在Windows注册表的哪里?
- 有一个好的Valgrind Windows的替代品吗?