Create file with a specific size..
Posted on 2003-11-05
Hi, I want to create a file with a specific size. I wrote this code:
string FILE_NAME = @"C:\test.data";
FileStream fs = new FileStream(FILE_NAME, FileMode.CreateNew);
BinaryWriter b = new BinaryWriter(fs);
const uint _byte = 1024;
ulong MB = (_byte * _byte) * UInt64.Parse(textBox1.Text.ToString()); //for example: 30
byte buffer = new byte[MB];
..and I have some questions:
Is this a bad way to do it?
How big file can I create this way?
Can I optimize the speed?