How to edit any .cs file from my C# application?

I want to replace all the private modifiers to public modifiers, in any given .cs file, using C# application.


Answer this question

How to edit any .cs file from my C# application?

  • Aji Jose

    Thank you Nilsson.

    Actually I want to write testcases in NUnit, for my UI (Forms). And I can't found a way for testing UI with NUnit. Please correct me, if there is a way.



  • nlhowell

    Why would you want that

    anyway here is something you can do (although I dont recomennd it)

    StreamReader r = new SreamReader("myapp.cs");
    string text = r.ReadToEnd().Replace("private", "public");
    r.Close();

    StreamWriter w = new StreamWriter("myapp.cs");
    w.Write(text);
    w.Flush();
    w.Close();


  • How to edit any .cs file from my C# application?