Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

the fastest way to create a file of specified size

Status
Not open for further replies.

Cosmin3

Programmer
Dec 9, 2010
10
RO
Hi.
What is the fastest way to create a file of a specific size (preferably without writing in it) on a nonNTFS partition..?
On a NTFS I use this:

Code:
var tf: TFileStream;
begin
....
tf := TFileStream.Create(FileName, fmCreate or fmShareExclusive);
tf.Size := [desired value];
tf.Free;

It's very fast.

But, for example, on FAT32 it's writing the entire file when the code reaches at "tf.Free".

Is there a better way...?
I searched the forum before asking but I couldn't find anything useful. But if there is please show me.

Thank you in advance for your help.

Best regards, Cosmin
 
In case someone is wondering why I need to create such files: I'm making a small utility to fill USB sticks/keys with dummy files(s) so it wouldn't get infected on other computers.
It works for the most of the viruses.
You can download the application from: It has 4 languages (automatic detection): English, French, Deutch, Romanian.

On NTFS it works very fast but on FAT32 is very slow.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top