Fast way to write 10GB blank file

I want to create fairly large blank files to use as emulated disk images.

I would like the files to contain only H"00" characters.

I have tried creating a 5MB memory block ( supposedly initialised to H"00"s ), obtaining its string value, and writing that over and over, but is is pretty slow. ( Platter drive, no SSD ).

TIA.

How to create large dummy file

Marvellous! That works treat. Thanks very much. :slight_smile:

or you just set position.

[code] // create 50 MB file
dim f as FolderItem = SpecialFolder.Desktop.Child(“test.txt”)
dim b as BinaryStream = BinaryStream.Create(f)

b.Position = 50 * 1024 * 1024 -1 // 50 MB
b.WriteUInt8 0 // write one byte
b.Close[/code]

[quote=274065:@Christian Schmitz]or you just set position.

[code] // create 50 MB file
dim f as FolderItem = SpecialFolder.Desktop.Child(“test.txt”)
dim b as BinaryStream = BinaryStream.Create(f)

b.Position = 50 * 1024 * 1024 -1 // 50 MB
b.WriteUInt8 0 // write one byte
b.Close[/code][/quote]

Yes, tried that, but file was not initialised to H"00" throughout. ( Unless I made a mistake ).

Really?
The OS should make it all zero file.

This works just fine for me.

  dim bs as BinaryStream
  if f.Exists then
    bs = BinaryStream.Open( f, true )
  else
    bs = BinaryStream.Create( f )
  end if
  bs.Length = 0
  bs.Length = kFileSize
  bs.Close

I apologise - I made a mistake as usual. You are quite correct. Thank you for your answer and your help. :slight_smile: