-2

I write a code to read many text files and grouped them in one file called (all.txt), after that I read all.txt file to count the word frequency, and the result appears in richtextbox. the code work well but the problem when I run the program, part of result appears then the program is hang without responding. I think that may be from memory, my computer RAM is 4 GB any help would be appreciated. note:my code work well in small text file.here's part of my code :

  StreamWriter w=new StreamWriter(@"C:\documents\all.txt");
            w.Write(all);
            w.Close();
dany
  • 1
  • 3
  • 1
    You talk about reading but your code is for writing ... Are you asking about latency due to loading 4 megabytes of text into a Windows Form RichTextBox control? – Alex K. Jun 08 '17 at 16:28
  • 1
    1) What's "miga"? Figure out if you're talking about megabytes or gigabytes and fix your question. 2) Why did you post a code snippet of writing to a file when your question is about reading? – itsme86 Jun 08 '17 at 16:37
  • Are you trying to update the RichTextBox as you read the file? Give us more details and some code that is relevant to your question. – Idle_Mind Jun 08 '17 at 17:23
  • thank you all for your comments, I think that the problem not in writing or reading the files instead it's in memory because when I read just a few files the program works without any problem so, I wonder if anyone could help me about that. – dany Jun 09 '17 at 15:53

1 Answers1

-1

If your problem is reading a large file, try using MemoryMappedFile as indicated in here

Pedro Drewanz
  • 1,242
  • 13
  • 14