usera Posted October 27, 2010 Share Posted October 27, 2010 Greeting, I am looking for a way to create a big size (like 100mb) file. The content of the file could be anything not important. the important is the size need to be exactly and big. what is the best way. Thanks usera Link to comment Share on other sites More sharing options...
czardas Posted October 27, 2010 Share Posted October 27, 2010 (edited) This is a strange request. What will you do with it after you create it? Here's a slow method, and I'm not sure of the exact size you will get. Local $data = "" While StringLen($data) < 10000000 $data &= Chr(Random(32, 126, 1)) WEnd For $i = 1 To 100 FileWrite("bigFile.txt", $data) Next oops, I missed something. Okay, something like this would be faster: Local $data = "00000000000000000000000000000000" While StringLen($data) < 1000000 $data &= $data WEnd For $i = 1 To 100 FileWrite("bigFile.txt", $data) Next Edited October 27, 2010 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Varian Posted October 27, 2010 Share Posted October 27, 2010 A quick google search for "create big size file" finds "fsutil"$Size_In_MB = 200 $Size = Number(1024*1024*$Size_In_MB) RunWait('fsutil file createnew NewFile ' & $Size, @DesktopDir, @SW_HIDE) If Not FileExists(@DesktopDir & '\NewFile') Then Exit MsgBox(0, 'ERROR', 'Cannot create NewFile') $ReadSize = FileGetSize(@DesktopDir & '\NewFile') / 1024 / 1024 Msgbox(32, 'File Created', 'NewFile size: ' & $ReadSize & ' MB') Link to comment Share on other sites More sharing options...
KaFu Posted October 27, 2010 Share Posted October 27, 2010 Or use FileSetPos()... #include <Constants.au3> Local Const $sFile = "test.txt" Local $hFile = FileOpen($sFile, 2) ; Check if file opened for writing OK If $hFile = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileSetPos($hFile, (1024*1024*100)-1, $FILE_BEGIN) FileWrite($hFile, 0) ; Close the handle. FileClose($hFile) OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Mison Posted October 27, 2010 Share Posted October 27, 2010 What is it for? Just curious. Hi ;) Link to comment Share on other sites More sharing options...
adik2dmax666 Posted October 27, 2010 Share Posted October 27, 2010 I think he is trying to make a bloater. First learn computer science and all the theory. Next develop a programming style. Then forget all that and just hack. -George Carrette[sub]GD Keylogger Creator (never released)[/sub][sub]Garena Autojoin v3.0[/sub] Link to comment Share on other sites More sharing options...
usera Posted October 27, 2010 Author Share Posted October 27, 2010 What is it for? Just curious.Thanks for ask, the reason for this, is a software (utility) need test for exactly size file for open and read it and have to be bigThanksusera Link to comment Share on other sites More sharing options...
usera Posted October 27, 2010 Author Share Posted October 27, 2010 Or use FileSetPos()... #include <Constants.au3> Local Const $sFile = "test.txt" Local $hFile = FileOpen($sFile, 2) ; Check if file opened for writing OK If $hFile = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileSetPos($hFile, (1024*1024*100)-1, $FILE_BEGIN) FileWrite($hFile, 0) ; Close the handle. FileClose($hFile) works and thanks Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now