I think you don't need that
StringBuilder
at all!
The following code:
StringBuilder UptoMain = new StringBuilder();
StreamWriter file = new StreamWriter(@"c:\temp.txt", false);
UptoMain.AppendLine(@"Here there is lots and lots of text which makes the code look very ugly and and messy to hande");
file.WriteLine(UptoMain);
can be reduced to:
StreamWriter file = new StreamWriter(@"c:\temp.txt", false);
string s = @"Here there is lots and lots of text which makes the code look very ugly and and messy to hande";
file.WriteLine(s);
This does not sort your problem with the long string though... If you really need to keep the string in code, all you can do is to move the string constant somewhere else. You can write something like:
private const string MyString = @"Here there is lots and lots of text which makes the code look very ugly and and messy to hande";
...and then use
MyString
in the code later. This will make your code more readable, since you can move the string constant declaration anywhere you like, even to a separate file.