Most efficiant use of stringbuilder

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Ryan McLean (Ryan.McLean_at_NAU.EDU)
Date: 09/01/04


Date: 1 Sep 2004 07:36:27 -0700

Hello everyone, I have a question for you. If I need to print 20,000
lines to a file which option is the most efficient?

(these are generated inside a datareader loop)

#1 Concatenate the data into a string variable, then write file at the
end of the loop (99.9% sure this is not it)
#2 Append the data into stringbuilder variable, then write file at the
end of the loop
#3 Append the data into stringbuilder variable, writing to the file
ever 500 or so records
#4 Don't use any variable, simply write directly to the file in every
iteration (99.9% sure this is not it either)

Thanks, I really appreciate your help. Have a great day!
Ryan



Relevant Pages

  • Re: what does "serialization" mean?
    ... >> resource reasons). ... >> other forms of writing saying what you really mean to say is a writing ... If you consider all loop forms of all languages, ... exposed "iteration" API. ...
    (comp.programming)
  • Re: writing data to multiple files
    ... Meaning that once I write to file ... , When the iteration starts over, I want to write the ... the file instead of creating then writing to a new file: ... is the same as just doing the loop once with K=1. ...
    (comp.soft-sys.matlab)
  • How to handle a multi-level variable
    ... I append lines ... and then use lineget to use the ones I need. ... iteration of the loop it is in to avoid duplicate values. ...
    (comp.sys.tandem)
  • Re: string concatenation efficiency
    ... but of course moving the Open and Close statements inside the loop ... even after an error that causes your program to terminate. ... You'll find that it contains every single log append right up to ... Dim s1 As String, n As Long ...
    (microsoft.public.vb.general.discussion)
  • Re: Please help... KRISH
    ... The loop would cycle once for each date between those limits. ... those dates not within a weekend, it would append one row to the table. ... "Tom Ellison" wrote: ... particular day then it should show all beds available (i..e., ...
    (microsoft.public.access.queries)