Jump to content

[Solved] File creation limit


UEZ
 Share

Recommended Posts

Why is there a limitation when creating files to hard disk?

E.g.

Local $dummy, $i, $path
For $i = 1 To 4096 ;4k filesize
    $dummy &= Chr(Random(33, 126, 1))
Next
$path = "E:\Test\Test."
For $i = 1 To 555
    FileOpen($path & $i, 2 + 8)
    FileWrite($path & $i, $dummy)
    FileClose($path & $i)
Next

This script will create 4k files on drive E: / folder Test with name Test.1 - Test.509 whereas last file is empty, although the For / Next loop is from 1 to 555.

Is this a limitation?

Thanks.

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Why do you need to make that many files?

Why not? :P

The reason is that my ext. 2.5" drive (80 GB) has a lot of bad sectors and I want to fill the whole disk with files to check them which are corrupt.

Only "good" files will be deleted - the rest will allocate bad sectors.

I wrote already a GUI but noticed that it creates only up to 509 files!

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

you are mixing file handles and filenames. This line in your code 'FileOpen($path & $i, 2 + 8)' is opening a opening a file that you never close so you run out of available file handels when you reach 509

From the the help file

"Note: Do not mix filehandles and filenames, i.e., don't FileOpen a file and then use a filename in this function. Either use filehandles or filenames in your routines, not both."

use either this method

Local $dummy, $i, $path, $hfile

For $i = 1 To 4096 ;4k filesize
    $dummy &= Chr(Random(33, 126, 1))
Next
$path = "E:\Test_1\Test."
For $i = 1 To 555
    $hfile = FileOpen($path & $i, 2 + 8)
    FileWrite($hfile, $dummy)
    FileClose($hfile)
NextoÝ÷ Øêí+&zØhu«­¢+Ù1½°ÀÌØíÕµµä°ÀÌØí¤°ÀÌØíÁÑ ()½ÈÀÌØí¤ôÄQ¼ÐÀäØìѬ¥±Í¥é(ÀÌØíÕµµäµÀìô
¡È¡I¹½´ ÌÌ°ÄÈذĤ¤)9áÐ(ÀÌØíÁÑ ôÅÕ½ÐíèÀäÈíQÍÑ|ÈÀäÈíQÍиÅÕ½Ðì)¥É
ÉÑ ÅÕ½ÐíèÀäÈíQÍÑ|ÈÅÕ½Ðì¤)½ÈÀÌØí¤ôÄQ¼ÔÔÔ(¥±]É¥Ñ ÀÌØíÁÑ µÀìÀÌØí¤°ÀÌØíÕµµä¤)9áÐ

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

you are mixing file handles and filenames. This line in your code 'FileOpen($path & $i, 2 + 8)' is opening a opening a file that you never close so you run out of available file handels when you reach 509

From the the help file

"Note: Do not mix filehandles and filenames, i.e., don't FileOpen a file and then use a filename in this function. Either use filehandles or filenames in your routines, not both."

use either this method

Local $dummy, $i, $path, $hfile

For $i = 1 To 4096 ;4k filesize
    $dummy &= Chr(Random(33, 126, 1))
Next
$path = "E:\Test_1\Test."
For $i = 1 To 555
    $hfile = FileOpen($path & $i, 2 + 8)
    FileWrite($hfile, $dummy)
    FileClose($hfile)
NextoÝ÷ Øêí+&zØhu«­¢+Ù1½°ÀÌØíÕµµä°ÀÌØí¤°ÀÌØíÁÑ ()½ÈÀÌØí¤ôÄQ¼ÐÀäØìѬ¥±Í¥é(ÀÌØíÕµµäµÀìô
¡È¡I¹½´ ÌÌ°ÄÈذĤ¤)9áÐ(ÀÌØíÁÑ ôÅÕ½ÐíèÀäÈíQÍÑ|ÈÀäÈíQÍиÅÕ½Ðì)¥É
ÉÑ ÅÕ½ÐíèÀäÈíQÍÑ|ÈÅÕ½Ðì¤)½ÈÀÌØí¤ôÄQ¼ÔÔÔ(¥±]É¥Ñ ÀÌØíÁÑ µÀìÀÌØí¤°ÀÌØíÕµµä¤)9áÐ
Thanks for your help.

I need to save path to a variable instead opening the handle which is limited to 509 handles. :P

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...