Creating Large Dummy Testing Files

In recent project I created the custom file uploader webpart. When it was time to test it, first thing was looking for some huge file.

At first I applied the simple logic using MS Word Lorem Macro trick. wooo I created 14000 pages but file size was just 3 MB. What !!! ?

That was surprise.

In end rescue was using power shell.

 $path = “$env:temp\testfile.txt”
$file = [io.file]::Create($path)
$file.SetLength(1gb)
$file.Close()
Get-Item $path
This created the 1GB test.txt file in my temp directory.
Advertisements

3 Comments

  1. Ben Chapman said,

    November 25, 2014 at 8:57 PM

    Thank you! This was very helpful – worked like a charm.

  2. Anders said,

    April 6, 2016 at 4:16 PM

    This problem with this is when you need actual content in the file. This fil will not be valid for application usage (eg as a log file to append further).

    • Anders said,

      April 6, 2016 at 4:19 PM

      Oops my bad, I didn’t close the file. Anyway the file is filled with binary zero FYI


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: