Windows: creating an empty file of a given size, or an analog of dd if=/dev/zero

Practice



Unix users have probably encountered the DD utility, which allows byte-by-byte copying from one file/device to another.

Personally, I most often use it in the following variants:

dd if=/dev/zero of=somefile bs=1M count=filesize
dd if=/dev/zero of=somefile bs=1M count=1 seek=filesize

What for? To create a file of a given size, consisting of zeros (/dev/zero).

But how do you create an empty file of a given size in Windows? After all, it certainly doesn't have the DD utility.

As a special case and an alternative to dd for this task, you can use the fsutil utility, which comes bundled with the operating system:

C:\> fsutil file createnew c:\myfile 1024000

In this example, we create an empty file filled with zeros and with a size of 1024000 bytes (almost 1MB).

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Operating Systems and System Programming"

Terms: Operating Systems and System Programming