thx!

On 30 nov, 00:15, Reuben Bartolo <[email protected]> wrote:
> exportRecords is the problem.
> Why are you keeping a List of objects?
> Do NOT ever load everything in memory.
> Load what you need now, use it, and dispose.
>
>
>
> On Sat, Nov 28, 2009 at 8:14 PM, janis <[email protected]> wrote:
> > I really REALLY hope that someone could help me.
>
> > I have to pass almost 400.000 records from a database to a textfile
> > Because of this amount the extension of the textfile is just something
> > I made up ...(.you_name_it)
> > I get an error while writing the data to the file at +/- 9000 records.
> > The error = Exception of type 'System.OutOfMemoryException' was thrown
> > And I don't know the solution :(
>
> > This is the peace of code I use for writing the records to the file.
>
> >         this.path_to_file =
> >         ConfigurationManager.AppSettings["ExportDir"] +
> > DateTime.Now.ToString(ConfigurationManager.AppSettings
> > ["Export_FileName"]) + ConfigurationManager.AppSettings
> > ["Export_Extension"];
>
> >         FileStream fm = new FileStream
> >            (this.path_to_file, FileMode.Create, FileAccess.ReadWrite,
> > FileShare.ReadWrite);
>
> >         StreamWriter sw = new StreamWriter(fm, Encoding.Default);
>
> >         List<Export> exportRecords = null;
>
> >         exportRecords = ExportList();
> >         try
> >         {
> >             int i = 0;
> >            foreach (Export ex in exportRecords)
> >            {
> >                sw.Write(ex.ExportLine());
> >               sw.Write(sw.NewLine);
> >               sw.Flush();
> >               exportlines += ex.ExportLine() + "\n";
> >                i++;
> >            }
> >         }
> >         catch (Exception exc)
> >         {
> >            Log.Write(exc.Message);
> >         }- Tekst uit oorspronkelijk bericht niet weergeven -
>
> - Tekst uit oorspronkelijk bericht weergeven -

Reply via email to