Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim FILENAME As String = Server.MapPath("Output2.txt")
Dim objStreamWriter As StreamWriter = New StreamWriter(FILENAME, False, Encoding.ASCII, 10000000)
Dim stringval As String
Dim whitespace As String
whitespace = 1
For x = 4 To 100000
whitespace = whitespace & x
Next
stringval = whitespace
objStreamWriter.WriteLine(stringval)
objStreamWriter.Flush()
objStreamWriter.Close()
End Sub
The code above works, it outputs a file at 480 kb - taking 2 minutes to do so.
What i'd like to ask the community is, could this process be cut down to less than 30 seconds or even better less than 10 seconds. I also like to add the actual output files i have are much larger than 400 KB, they are in the 1 to 2 MB (more than 100000 characters).
At this moment, i would prefer sticking with this method to write out strings to a text file - however i am open to suggestions depending on how easy it is to migrate to the other method.
As you notice, i have no idea why but i read some where specifying a large buffersize increases performance, however i don't notice this at all when i left it on default or not.
Regards,
Joker.