Howto: Create a File of whatever size you want in Windows

You can create a file of any size using nothing more than what’s supplied with Windows.

There comes a time in every developers life where they need a data file for testing purposes and there are none handy. Rather than searching around for a file that fits your needs, the easiest thing to do is simply to generate one. There are a number of reasons why you might want to generate a data file. For example, recently we needed to test the file upload functionality of a little application we were writing at work, using a whole range of files of different sizes (from <1Mb up to >100Mb).

Rather than hunt around for files that would fit the bill, it was a lot easier to just generate some. Another reason might be when you need to test some functionality (e.g. algorithm) to see how it would handle very large sets of data. Since you normally don’t have files that are 1Gb or more in size just lying around, generating some is probably a good way to go.

Start by converting the desired file size into hexadecimal notation. You can use the Windows Calculator in Scientific mode do to this. Suppose you want a file of 1 million bytes. Enter 1000000 in the calculator and click on the Hex option to convert it (1 million in hex is F4240.) Pad the result with zeroes at the left until the file size reaches eight digits—000F4240.

  • Now open a command prompt window. In Windows 95, 98, or Me, you can do this by entering COMMAND in the Start menu’s Run dialog; in Windows NT 4.0, 2000, or XP/Windows7 enter CMD instead.
  • Enter the command DEBUG BIGFILE.DAT and ignore the File not found message.
  • Type RCX and press Enter. Debug will display a colon prompt. Enter the last four digits of the hexadecimal number you calculated (4240, in our example).

cmd-commands-large-size

  • Type RBX and press Enter, then enter the first four digits of the hexadecimal size (000F, in our example).
  • Enter W for Write and Q for Quit. You’ve just created a 1-million-byte file using Debug. Of course you can create a file of any desired size using the same technique.

cmd-commands-large-size-dir

 

In the above screenshot you can see “BIGFILE.DAT” with size of 1,000,000 bytes.

cmd-commands-large-size-explorer

 

This is the screenshot from explorer. Now you can create file of whatever size you want according to needs.