Hey guys!
There is some way to open a file and fill it with randon information until it reach a determined value?

Like a dumb file (;

Thanks!

Have you attempted this with the code provided in your File wipe & drag-n-drop support thread?

By means of "a determined value", is that for file size or the content length in your file?

Yeah, i first thought on that, but that only fills a file with random chars.

When I mean fill a file with a predefined size its like, create a file and add random data to it until it reaches x kb/mb/gb/whatever.

There is a way to control it?

>There is a way to control it?
Why not? Save file every so often, check for file size and if not at your standard, add more content and save again.

Dim myCoolFileInfo As New IO.FileInfo("C:\test.txt") '// your file.
        MsgBox(CInt(myCoolFileInfo.Length).ToString("#,###,###,###,###") & " bytes") '// file size.

Thank you!
I'll try it as soon as I get VS installed again.

Just one more thing: the code you provided to me in the other thread added random information, but it was always the same information. It was like copy and paste the same part of a string a million times.

There is a way to generate a more random string, something new everytime it add more info?

>There is a way to generate a more random string, something new everytime it add more info?
You could load a file with thousands of random lines into an ArrayList and randomly select an item from the ArrayList to add to your file content and if needed, inject characters/.Substrings from that random item all throughout your file.

Can you please help me with this? I don't know how to work with arrays yet :x

An ArrayList is nothing more than a ListBox.
For example, adding an item to a ListBox, you use: ListBox1.Items.Add("test item") ... and adding an item to an ArrayList, you just use: myArrayList.add("test item") without the".Items".

See if this helps.
1 Button

Public Class Form1
    Private myFile As String = "C:\test.txt" '// your file.
    Private arlCoolArrayList As New ArrayList '// ArrayList used to load file lines/etc..
    Private rndArrayListItems As New Random '// for randomizing.

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If IO.File.Exists(myFile) Then arlCoolArrayList.AddRange(IO.File.ReadAllLines(myFile)) '// Load File Lines into Array List.
        '// add some items yourself if needed.
        arlCoolArrayList.Add("new item added to ArrayList")
        arlCoolArrayList.Add("add another, just because you can :D")
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        rndArrayListItems = New Random '// setting it as New Random usually returns a more random #.
        '// randomize from 0 to .Count, since using 0 to .Count-1 will not consider the last item.
        Dim iRandomNumber As Integer = rndArrayListItems.Next(0, arlCoolArrayList.Count)
        If Not arlCoolArrayList.Count = 0 Then ' check if items in ArrayList.
            MsgBox(arlCoolArrayList(iRandomNumber)) '// Display result.
        End If
        'arlCoolArrayList.Remove("new item added to ArrayList") '// remove item by String.
        '// Or...
        'arlCoolArrayList.RemoveAt(iRandomNumber) '// remove item by Index.
    End Sub
End Class

I need a bit more of help here.

Here are my codes 'til now:
The main dialog:

Imports System.IO

Public Class Main
    Dim FileName As String
    Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        If SaveFile.ShowDialog = Windows.Forms.DialogResult.OK Then
            FileName = SaveFile.File[CODE][/CODE]Name
            lblDestinationText.Text = SaveFile.FileName
        End If
    End Sub

    Private Sub btnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreate.Click
        ProgressControl.ShowDialog()
    End Sub

    Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        comboTypes.SelectedItem = "Byte(s)"
    End Sub
End Class

The secondary dialog:

Public Class ProgressControl

    Private Sub ProgressControl_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        barProgress.Maximum = Main.FileSize.Value
        lblFileName.Text = Main.SaveFile.FileName
        lblTotalSize.Text = Main.FileSize.Value & " " & Main.comboTypes.SelectedItem
    End Sub
End Class

I can't manage a way to limit the file size. The code you provided shows the actual file size, but I'm lacking the logic to make it useful. If statements?

Also, I want to make that progressbar to work. If I can limit the file size, I think it will be easier to make it working, since it will just change a bit: instead of checking to see if it is large enough, it will take the current size value and apply to the bar.

Any suggestions?

See if this helps.
1 Button

Imports System.IO
Public Class Form1
    Private myFile As String = Nothing

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Show()
        Dim ofd As New OpenFileDialog : If ofd.ShowDialog = DialogResult.OK Then myFile = ofd.FileName
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        addContentToFile(4000, myFile)
    End Sub

    Private Sub addContentToFile(ByVal myPresetFileSizeInBytes As Integer, ByVal myFileToAddContentTo As String)
        Dim myFileInfo As IO.FileInfo
        Dim sTemp As String = "some content to add to the file." & vbNewLine
        Dim iFileSize As Integer = 0 '// keeps track of file size.
        Do Until iFileSize >= myPresetFileSizeInBytes '// loop Until the file size equals or is greater than the preset file size you need.
            myFileInfo = New IO.FileInfo(myFileToAddContentTo) '// used to get file size.
            iFileSize = CInt(myFileInfo.Length) '// set the file size.
            '// write back file content after reading it and adding extra content.
            File.WriteAllText(myFileToAddContentTo, File.ReadAllText(myFileToAddContentTo) & sTemp)
        Loop
        MsgBox("done")
    End Sub
End Class

>Also, I want to make that progressbar to work.
If using the code I recently posted, you could set the ProgressBar1.Maximum to myPresetFileSizeInBytes and change the value of the ProgressBar with iFileSize.
Before changing the value, check if ProgressBar1.Maximum > iFileSize, else set ProgressBar1.Maximum to iFileSize and change the value then.
This should only be needed towards the end of writing content to your file.

Allright, here is a problem.

I want to create the file, not just open it. I think that I make it working:

Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        If SaveFile.ShowDialog = Windows.Forms.DialogResult.OK Then
            FileName = SaveFile.FileName
            lblDestinationText.Text = SaveFile.FileName
            Dim newfile As New FileStream(FileName, FileMode.Create)
        End If
    End Sub

At least, the file gets created. But, it doesn't add any content to it. Here's the entire code:

Imports System.IO

Public Class Main
    Dim FileName As String
    Dim FinalSize As Integer
    Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        If SaveFile.ShowDialog = Windows.Forms.DialogResult.OK Then
            FileName = SaveFile.FileName
            lblDestinationText.Text = SaveFile.FileName
            Dim newfile As New FileStream(FileName, FileMode.Create)
        End If
    End Sub

    Private Sub btnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreate.Click
        ProgressControl.ShowDialog()
    End Sub

    Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        comboTypes.SelectedItem = "Byte(s)"
    End Sub

    Private myFile As String = Nothing

    'Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    '    Me.Show()
    '    Dim ofd As New OpenFileDialog : If ofd.ShowDialog = DialogResult.OK Then myFile = ofd.FileName
    'End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreate.Click
        If comboTypes.SelectedItem = "bytes" Then
            addContentToFile(FileSize.Value, FileName)

        ElseIf comboTypes.SelectedItem = "Kilobytes" Then
            Finalsize = FileSize.Value * 1024
            addContentToFile(Finalsize, FileName)

        ElseIf comboTypes.SelectedItem = "Megabytes" Then
            Finalsize = FileSize.Value * 1024 * 1024
            addContentToFile(Finalsize, FileName)

        ElseIf comboTypes.SelectedItem = "Gigabytes" Then
            Finalsize = FileSize.Value * 1024 * 1024 * 1024
            addContentToFile(Finalsize, FileName)
        End If

    End Sub

    Private Sub addContentToFile(ByVal myPresetFileSizeInBytes As Integer, ByVal myFileToAddContentTo As String)
        Dim myFileInfo As IO.FileInfo
        Dim sTemp As String = "some content to add to the file." & vbNewLine
        Dim iFileSize As Integer = 0 '// keeps track of file size.
        Do Until iFileSize >= myPresetFileSizeInBytes '// loop Until the file size equals or is greater than the preset file size you need.
            myFileInfo = New IO.FileInfo(myFileToAddContentTo) '// used to get file size.
            iFileSize = CInt(myFileInfo.Length) '// set the file size.
            '// write back file content after reading it and adding extra content.
            File.WriteAllText(myFileToAddContentTo, File.ReadAllText(myFileToAddContentTo) & sTemp)
        Loop
        MsgBox("done")
    End Sub
End Class

I haven't changed what you did. Not a lot, at least. What is going wrong?

EDIT:
Found some errors, changed the code:

Imports System.IO

Public Class Main

    Dim FileName As String
    Dim FinalSize As Integer
    Dim Contents As ArrayList

    Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        If SaveFile.ShowDialog = Windows.Forms.DialogResult.OK Then
            FileName = SaveFile.FileName
            lblDestinationText.Text = SaveFile.FileName
        End If
    End Sub

    Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        comboTypes.SelectedItem = "Byte(s)"
        Contents.Add("範♓稌垫䎁᱃嵕줐㍁쉻杼煼濴㣒⻮왺籱㢾䥼")
        Contents.Add("魓᬴윖芚⬸쟺誸픐㹄৴留疆鹚")
        Contents.Add("ꘐ쿲쌺㪆롣泷琓蘇펁댾켍㫭片奻㠃‡軓뎄ᦚ棬뎠퇤凞꺸ᣢ⎘፼ા뺵禡飺譏ꜙꐊ㤮䭯ꪍ")
        Contents.Add("伣꨼ᅹ쇏Ὣ㻿삇⪘삑튐渢ᇹ톬姙攏")
        Contents.Add("쑖퐟驿몰⁢㦌ᩉ佯炆쏬䶅籯鏜黫伔∺㿹࣫瘺諾첼⤊ᗊ걹ᴴ狿३")
        Contents.Add("昷ퟭꫣ뻥ꮴꂍ퉅栴娕댓ʢᄇ㺉麎褣挹팞")
        Contents.Add("؅楈尳薐줛ꊓ蕣庺㞝ᾙ栳츷㹰劼ꑲ")
        Contents.Add("ᆉ斫坧ƽ䬱첷ᓨ幁窞俕꠸䜺ྨ剑旷㷈")
        Contents.Add("閘玖掼쏵脰搬䉥₃棥猂衶䌭ꡱ븗삽隫⽹")
        Contents.Add("斳셹茏ᢟ群共摫㵁釘꾔ޞ歅챗앑颸앚ሁ亯ꍗ")
        Contents.Add("枺鉱梉챍쉄ڸ٣躑압呀ɰ쌻ᚿ儶ᡯ纆되⼤훊替ખ뭰꜌뛆얲柾暟濶멖爱⭜㨼껭拡练暽羑ា聐ꪞḚ닟뒾კ趥騴䖭퉿ឺ僔缂얡")
        Contents.Add("论鈖寊₄펚⿕੆쵯踧ꀇ껖夡觹뭫뼤擤蘊ꑟ셗숪홯⣌겿ᦺ枵⨺ᄧᩨ蜋閮僨⺪膃ㅁ꽗庹⏩䊽矻䈄簤允䵟㰻ꊵ篭遾㤨菘猐р╔錟沂歱")
        Contents.Add("偡ࡪ꾕눩짌竖䰵緬蒄鯰䮴㏁佫뤕⎶鲦滿닡⃤薎")
        Contents.Add("Ƥ䌤ㅪፁ솰鈆湙檣릭⹫偊報឵潻댃㖖珫ꡗ詢엵꒱ヱ晼痺풷ᄒ")
        Contents.Add("ᐑ勿☑఩뫹ᴺ꫊瑬浹⠯䫢䏊ഝ૫怯ಲ헑誷黻")
        Contents.Add("帋֚뭊灻♥櫖麘⽮")
        Contents.Add("촳ʂ䘋ꏍ큘믙贆ꀋ充Ⱐ캆ṕㄷ㕸ᢺꃿ軳َ퇚䫭࢜硟毷Ⳓ䅎➬챗䨷㣩૤粙㽑佶㰿䴲뾿荩举┗꫎ീ덙⁺划✞벓穛섙荣㫭nj풽쐲㥪ꒅ䐼쏦Ổ頮괫쌧唵䫁䮽㼩残ꗵ⦒娟媼뜷픽ꃛ쾮Ⴢ쪬ἃ㥼窸⿎퓀퇛灵待ⅹ㴺ꅬ쟹䅶鱖")
        Contents.Add("랮끰폱鋔胦쮉✭峧␻䜃獧뇑飡螙㿽⹋殊漷뜀灢")
    End Sub

    Private myFile As String = Nothing

    'Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    '    Me.Show()
    '    Dim ofd As New OpenFileDialog : If ofd.ShowDialog = DialogResult.OK Then myFile = ofd.FileName
    'End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreate.Click

        Dim newfile As New FileStream(FileName, FileMode.Create, FileAccess.ReadWrite)

        If comboTypes.SelectedItem = "Bytes" Then
            addContentToFile(FileSize.Value, FileName)

        ElseIf comboTypes.SelectedItem = "Kilobytes" Then
            FinalSize = FileSize.Value * 1024
            addContentToFile(FinalSize, FileName)

        ElseIf comboTypes.SelectedItem = "Megabytes" Then
            FinalSize = FileSize.Value * 1024 * 1024
            addContentToFile(FinalSize, FileName)

        ElseIf comboTypes.SelectedItem = "Gigabytes" Then
            FinalSize = FileSize.Value * 1024 * 1024 * 1024
            addContentToFile(FinalSize, FileName)
        End If

    End Sub

    Private Sub addContentToFile(ByVal myPresetFileSizeInBytes As Integer, ByVal myFileToAddContentTo As String)
        Dim myFileInfo As IO.FileInfo
        Dim sTemp As String = "some content to add to the file." & vbNewLine
        Dim iFileSize As Integer = 0 '// keeps track of file size.
        Do Until iFileSize >= myPresetFileSizeInBytes '// loop Until the file size equals or is greater than the preset file size you need.
            myFileInfo = New IO.FileInfo(myFileToAddContentTo) '// used to get file size.
            iFileSize = CInt(myFileInfo.Length) '// set the file size.
            '// write back file content after reading it and adding extra content.
            'File.WriteAllText(myFileToAddContentTo, File.ReadAllText(myFileToAddContentTo) & sTemp)
            File.WriteAllLines(myFileToAddContentTo, Contents)
        Loop
        MsgBox("done")
    End Sub
End Class

However, it still 'ignore' the write function. It simply passes as if it wasn't there.

Do you want to add random item content from the ArrayList or just a specified item in the ArrayList?

Do you want to add random item content from the ArrayList or just a specified item in the ArrayList?

As random as possible. (:

See if this helps.
Add a BackgroundWorker and a ProgressBar to your Form.

Imports System.IO
Public Class Main
    Private FileName As String, FinalSize As Integer, arlContents As New ArrayList

    Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        If SaveFile.ShowDialog = Windows.Forms.DialogResult.OK Then
            FileName = SaveFile.FileName
            lblDestinationText.Text = SaveFile.FileName
            If Not File.Exists(FileName) Then File.WriteAllText(FileName, "") '// create blank file if it does not exist.
        End If
    End Sub

    Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Control.CheckForIllegalCrossThreadCalls = False '// allow cross threading for the BackgroundWorker.
        comboTypes.SelectedItem = "Byte(s)"
        arlContents.Add("範♓稌垫䎁᱃嵕줐㍁쉻杼煼�濴㣒�⻮왺籱ﺁ㢾䥼")
        arlContents.Add("ﰓ魓�᬴윖�芚⬸쟺誸픐㹄৴留疆鹚")
        arlContents.Add("ꘐ쿲쌺㪆롣泷琓蘇펁댾켍㫭片奻㠃‡軓뎄ᦚ棬뎠﯊퇤凞꺸ᣢ⎘¬፼ા뺵禡飺譏ꜙꐊ㤮䭯ꪍ")
        arlContents.Add("伣꨼ᅹ쇏Ὣ㻿삇⪘삑튐渢ᇹ톬姙攏")
        arlContents.Add("쑖퐟驿몰⁢㦌ᩉ佯炆쏬䶅籯鏜黫伔∺㿹࣫瘺諾첼⤊ᗊ걹ᴴ狿३")
        arlContents.Add("昷ퟭꫣ뻥ꮴꂍ퉅栴娕댓ʢvᄇ㺉麎褣挹�팞")
        arlContents.Add("؅楈尳薐줛ꊓ蕣庺㞝ᾙ栳츷㹰劼ꑲ")
        arlContents.Add("ᆉ斫坧ƽ䬱첷ᓨ幁窞俕꠸䜺ྨ剑旷㷈")
        arlContents.Add("閘玖掼쏵脰搬䉥₃棥猂衶䌭ꡱ븗삽勵隫⽹")
        arlContents.Add("斳셹茏ᢟ群共摫㵁釘꾔ޞ歅챗앑颸앚ሁ亯ꍗ")
        arlContents.Add("枺鉱梉챍쉄ڸ٣躑압呀ɰ쌻ᚿ儶ᡯ纆되⼤훊替ખ뭰꜌뛆얲柾暟濶멖爱ﰱ⭜㨼껭拡练�暽羑ា聐ꪞḚ닟뒾კ趥騴䖭퉿ឺ僔缂얡")
        arlContents.Add("论鈖寊₄펚⿕੆쵯踧ꀇ껖夡觹뭫뼤�擤露蘊ꑟ셗숪홯⣌겿ᦺ枵⨺ᄧᩨ蜋閮僨⺪膃ㅁ꽗庹⏩䊽矻䈄簤允䵟㰻ꊵ�篭遾㤨菘猐�р╔錟沂歱")
        arlContents.Add("偡ࡪ꾕復눩�짌竖䰵緬�蒄鯰䮴㏁�佫뤕⎶鲦滿닡⃤薎益")
        arlContents.Add("Ƥ䌤ㅪፁ솰鈆湙檣難릭⹫偊報�឵潻댃㖖珫ꡗ詢엵꒱ヱ晼痺풷ᄒ")
        arlContents.Add("ᐑ勿☑఩뫹ᴺ꫊瑬浹⠯䫢ロ䏊ഝ૫怯�ಲ헑�誷ﰏ黻")
        arlContents.Add("帋֚뭊灻♥櫖麘ﴣ⽮")
        arlContents.Add("촳ʂ䘋ﱙꏍ큘믙贆ꀋ充Ⱐ캆ṕㄷ㕸ᢺꃿﯗ軳َ퇚䫭࢜硟毷�Ⳓﹶ䅎➬챗䨷㣩૤粙㽑佶㰿䴲뾿荩举┗꫎ീ덙⁺划✞벓穛섙荣㫭nj풽쐲㥪ꒅ䐼쏦Ổ頮괫쌧唵䫁䮽㼩残ꗵ⦒娟媼뜷픽ꃛ쾮Ⴢ쪬�ἃ㥼ﵺ窸⿎ヒ퓀퇛灵待ⅹ㴺ꅬ쟹䅶鱖")
        arlContents.Add("랮끰폱鋔胦쮉✭峧␻䜃獧뇑飡螙㿽⹋殊漷뜀灢")
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreate.Click
        '// set value for FinalSize.
        If comboTypes.SelectedItem = "Bytes" Then
            FinalSize = FileSize.Value
        ElseIf comboTypes.SelectedItem = "Kilobytes" Then
            FinalSize = FileSize.Value * 1024
        ElseIf comboTypes.SelectedItem = "Megabytes" Then
            FinalSize = FileSize.Value * 1024 * 1024
        ElseIf comboTypes.SelectedItem = "Gigabytes" Then
            FinalSize = FileSize.Value * 1024 * 1024 * 1024
        End If
        BackgroundWorker1.RunWorkerAsync() '// Start.
    End Sub

    '// RUN THE CODE ON A SEPARATE THREAD BY USING A BACKGROUNDWORKER.  DOES NOT FREEZE APP. WHILE RUNNING.
    Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        addContentToFile(FinalSize, FileName)
    End Sub

    Private Sub addContentToFile(ByVal myPresetFileSizeInBytes As Integer, ByVal myFileToAddContentTo As String)
        ProgressBar1.Maximum = myPresetFileSizeInBytes
        ProgressBar1.Value = 0
        Dim myFileInfo As IO.FileInfo
        Dim iFileSize As Integer = 0 '// keeps track of file size.
        Dim rnd As New Random '// randomize items in ArrayList.
        Do Until iFileSize >= myPresetFileSizeInBytes '// loop Until the file size equals or is greater than the preset file size you need.
            myFileInfo = New IO.FileInfo(myFileToAddContentTo) '// used to get file size.
            iFileSize = CInt(myFileInfo.Length) '// set the file size.
            If iFileSize >= ProgressBar1.Maximum Then ProgressBar1.Maximum = iFileSize
            ProgressBar1.Value = iFileSize
            '// write back file content after reading it and adding a random item from the ArrayList.
            File.WriteAllText(myFileToAddContentTo, File.ReadAllText(myFileToAddContentTo) & arlContents(rnd.Next(0, arlContents.Count)))
        Loop
        MsgBox("done")
    End Sub
End Class

It is working, but it takes too long!
I mean, it is like it fills the file a bit then it cleans it.
Then it fills a bit more, and cleans.

It is also taking too long to start the process :x
Maybe is because the array randomizing?

>It is also taking too long to start the process :x
Get a faster p.c.. :D

I also noticed that for a 10 MB file, it can take a few minutes to create the file.

See if this helps.
You could run a process before starting the process to save to the file.
This process would be to save each item in your ArrayList to a file and retrieve the file size only for that item, then move on to the next item. Store the file sizes for each item either in another ArrayList of List(of Integer, and use that for references.
.Then instead of loading the file, reading it, adding a random ArrayList item to the end of the file and saving back to the file, you could just load a String in your app with random items and use the file size references to determine the "final" file size. Then save the file once and done. It might speed up your application quite a bit.
Btw, I think this process would be called: "Optimize the application on start-up for quicker results."

>Maybe is because the array randomizing?
Randomizing numbers is like giving you a choice to pick a number from 0 to 1 billion. Not time consuming at all, or is it?:D

Good luck.

>It is also taking too long to start the process :x
Get a faster p.c.. :D

I also noticed that for a 10 MB file, it can take a few minutes to create the file.

See if this helps.
You could run a process before starting the process to save to the file.
This process would be to save each item in your ArrayList to a file and retrieve the file size only for that item, then move on to the next item. Store the file sizes for each item either in another ArrayList of List(of Integer, and use that for references.
.Then instead of loading the file, reading it, adding a random ArrayList item to the end of the file and saving back to the file, you could just load a String in your app with random items and use the file size references to determine the "final" file size. Then save the file once and done. It might speed up your application quite a bit.
Btw, I think this process would be called: "Optimize the application on start-up for quicker results."

>Maybe is because the array randomizing?
Randomizing numbers is like giving you a choice to pick a number from 0 to 1 billion. Not time consuming at all, or is it?:D

Good luck.

My pc is not that bad, you can see in my profile (:
Also, I solved the speed problem. There isn't a way to restrict the random number range?

>There isn't a way to restrict the random number range?

Dim rnd As New Random
        MsgBox(rnd.Next(0, 2)) '// rnd.Next(Minimum value, Maximum value) - this will return either a 0 or a 1, not a 2.

But it seems to be restricted. Why it would take so long to randomize then?

How many items is it randomizing? Just the ones from the code in your ArrayList? Then it is not the randomizing taking the time, it is the "loading the file, reading it, and saving it again".

Just figured that. It will read the file each time it writes it. Since it grows, it takes longer to read.

There is some way to just append the content, without reading it? I already have this:

Private Sub addContentToFile(ByVal myPresetFileSizeInBytes As Integer, ByVal myFileToAddContentTo As String)

        ProgressBar1.Maximum = myPresetFileSizeInBytes
        ProgressBar1.Value = 0

        Dim myFileInfo As IO.FileInfo
        Dim iFileSize As Integer = 0 '// keeps track of file size.
        Dim rnd As New Random '// randomize items in ArrayList.

        Do Until iFileSize >= myPresetFileSizeInBytes '// loop Until the file size equals or is greater than the preset file size you need.
            myFileInfo = New IO.FileInfo(myFileToAddContentTo) '// used to get file size.
            iFileSize = CInt(myFileInfo.Length) '// set the file size.
            If iFileSize >= ProgressBar1.Maximum Then ProgressBar1.Maximum = iFileSize
            ProgressBar1.Value = iFileSize
            '// write back file content after reading it and adding a random item from the ArrayList.
            File.AppendAllText(myFileToAddContentTo, arlContents(rnd.Next(0, arlContents.Count)))
          Loop
        MsgBox("done")
    End Sub

But, I want that everytime it appends to the file, it replicate the file content plus the new info randomized from the array. If it could do it without reading the file, the speed will be nice!

Quick edit:
By 'do it without reading the file' I meant read it to the end and then replicate the content (;

Could you replicate a car if you did not know what the car looks like minus well know what a car is?

>But, I want that everytime it appends to the file, it replicate the file content plus the new info randomized from the array. If it could do it without reading the file,...
My answer would be that this cannot be done, although I could be wrong.

Well, this make things harder. There IS another program over the web called Dummy File Creator, or something like that. Here is it's site: http://www.mynikko.com/dummy/

Its speed are amazing. I created a 1GB dummy file within two minutes. With my program, it can take a half hour.

Here is its approach:

File Stream -
Unlike previous version, Dummy File Creator 1.2 generates files in 4MB increment in order to increase performance of large file generation. To generate a 50MB file, Dummy File Creator will write 4MB data chunk 12 times and a 2MB chunk once to complete the task. In most cases, this behavior is unnoticeable. However, for people who would like to fill a disk drive with a larger-than-capacity dummy file. Dummy File Creator will try to fill the drive with closest size in 4MB increment. For example, if you are trying to fill a 50MB SD Card with a 1GB dummy file, Dummy File Creator will report an error and abort the operation after the size of generated file reaches 48MB, not 50MB as the software was unable to complete the writing task of the last 4MB data chunk. For data wiping purpose, this is already sufficient as all the of the available space was filled before the disk full error occurs; it is just that the last write operation attempt failed and resulted a size gap. Please keep this in mind if you are performing similar tasks.
Random Content -
Dummy File Creator 1.2 writes random bytes ranging from 0 to 255. However, unlike previous version which generates true random file content, Dummy File Creator 1.2 uses a different approach in random content generation in order to increase the performance of random content generation. Dummy File Creator now will generate 4MB of random data and reuse the same data by altering only some bytes at random locations for each subsequent write. While the result still defeats all of the compression software we tested (i.e. a larger compressed file than the original size), but it is still possible to compress this pseudo-random content if a specifically designed compression algorithm targeted at Dummy File Creator (very unlikely) is used. To design such algorithm, it must use dictionary words with length ranging from 1 to 4,194,303 bytes. Most people will not notice this change, but for people who are developing compressing algorithms, it is recommended to use the previous version which generates true random contents (but much slower) for testing.
Compressible Content -
Dummy File Creator 1.2 still writes ' ' (space character, Decial: 34, HEX: 20) as repeated content.

How can I do it, the same way, with the same speed? I know I could simply use Nikko's app, but I like to try by my own. I've also tried a increasing var, that each time it is used, it gets bigger, but the app simply use a LOT of memory. I started to think on a temp file or something.

What the hell I can do?
(no, I'm not nervous, I just thought that this would make a nice scene (; )

>What the h.ll I can do?
Test out different theories and see which results better your application.
You have all the needed resources in this thread to do so, you just have to find the correct code equation to do it with. That is not for me to do. I just try and supply suggestions and/or possible solutions, not create entire applications.

Good luck.

And btw, not a nice scene at all.
>...I just thought that this would make a nice scene...

>What the h.ll I can do?
Test out different theories and see which results better your application.
You have all the needed resources in this thread to do so, you just have to find the correct code equation to do it with. That is not for me to do. I just try and supply suggestions and/or possible solutions, not create entire applications.

Good luck.

And btw, not a nice scene at all.
>...I just thought that this would make a nice scene...

That makes sense (:
Thanks for the help, I try to find out now by my own.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.