I am trying to parse the code of a MainForm.cs file. As you can imagine it contains texts like:
string name = "Name: "+var1;
I presume the code below will just break on the first quotes it finds?
string text = System.IO.File.ReadAllText(@"C:\Project\MainsForm.cs");
So what would work?
The ReadAllText
method will read the entire file, quotation marks and all. When you parse it, the string will contain quotation marks. There is nothing in C# that prevents strings from containing quotation marks. For example, one could define a string as:
string quotedValue = "This string contains some \"air quotes\"";
And it would work.