Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 480523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:54:05+00:00 2026-05-13T00:54:05+00:00

I really REALLY hope that someone could help me. I have to pass almost

  • 0

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);
        }
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T00:54:05+00:00Added an answer on May 13, 2026 at 12:54 am

    Why is this line in your code?

          exportlines += ex.ExportLine() + "\n"
    

    Assuming it is a string variable it grows and grows and grows… and consumes memory.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hope that someone could help me with the following problem because I'm really
This is my first post here and I really hope, that someone could help
I have a problem with the esmtp application that I really hope you help
I'm almost losing it, i really hope someone can help me out! I'm using
I have a really hard time understanding routes and I hope someone can help
I really hope someone can help on this because I'm learning cocoa and have
I am really new to this website. I hope someone could help me out
I'm struggling to meet a demand from my supervisors. I really hope that someone
I am lost and really hope someone could help me out here, I am
hope to get some help here because this is something that really makes me

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.