Question C# Streamwrite - Huge String

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

GAFO666

Hacker
Meme Tier VIP
Aug 19, 2012
520
3,188
23
Hey Guys,
Im trying to write a realy huge string to a file, its around 90.000.000 Characters . Probably there will be even huger strings soon :F

The Problem which occurs is that if I use

C++:
 using (StreamWriter outfile = new StreamWriter(path + filename))
 {
      outfile.Write(hugeAssText);
 }
I get an OutOfMemory IO Exception o_O tried the Binarywriter too but all the time this weird exception.
Normaly you dont need to Handle the memory in c# yourself like in c++, so what should I use to write this huge text into a file ? o_O

,greetings
 

Solaire

Respected Hacker
Dank Tier VIP
Dec 15, 2013
1,051
16,353
62
Break it into pieces and write sections of it at a time.
 

GAFO666

Hacker
Meme Tier VIP
Aug 19, 2012
520
3,188
23
Break it into pieces and write sections of it at a time.
ye tried that with the binarywriter too

(tb1 contains the huge string, tb2 the filename - blank)
C++:
           if (textBox1.TextLength >= 28000000)
                {
                    int step_size = 28000000;
                    int step_count = textBox1.TextLength / step_size;                   

                    int cur_begin = 0;
                    int cur_end = step_size;

                    textBox4.AppendText("TextBoxCharacterCount: " + textBox1.TextLength.ToString() + Environment.NewLine);
                    for (int i = 0; i < step_count; i++)
                    {  

                        string sub = textBox1.Text.Substring(cur_begin, cur_end);
                        if (i == 0)
                        {

                            BinaryWriter writer = new BinaryWriter(new FileStream(AppDomain.CurrentDomain.BaseDirectory + textBox2.Text + ".h", FileMode.Create, FileAccess.Write));
                            writer.Write(sub);
                            writer.Close();
                        }
                        else
                        {
                            BinaryWriter writer = new BinaryWriter(new FileStream(AppDomain.CurrentDomain.BaseDirectory + textBox2.Text + ".h", FileMode.Open, FileAccess.Write));
                            writer.Write(sub);
                            writer.Close();
                        }

                        cur_begin = cur_end + 1;
                        cur_end = cur_end + step_size;
                    }                   

                    string end = textBox1.Text.Substring(cur_begin, textBox1.TextLength);
                    BinaryWriter end_writer = new BinaryWriter(new FileStream(AppDomain.CurrentDomain.BaseDirectory + textBox2.Text + ".h", FileMode.Open, FileAccess.Write));
                    end_writer.Write(end);
                    end_writer.Close();
                }
                else
                {
                    BinaryWriter writer = new BinaryWriter(new FileStream(AppDomain.CurrentDomain.BaseDirectory + textBox2.Text + ".h", FileMode.Create, FileAccess.Write));
                    writer.Write(textBox1.Text);
                    writer.Close();
dunno whats wrong with that, didnt work that much with c# soooo ...
out of memory at the sub string, even the size limit is at 2^32 (something around 4.000.000.000) and the part is only 28.000.000


and if i create a new string as object, its still 2.147.483.647 characters, which are above 28.000.000 ...... makes no sense at all
 
Last edited:
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods