Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to delete all the commented section i.e between <!----> from the config file using c#.Pls help.
Posted

1 solution

You could do it with a Regex:
C#
(\<!--)(.*?)-\>)

Read your file into a string, regex it, and write it back:
C#
string data = File.ReadAllText(path);
string noComments = Regex.Replace(data, @"(\<-)(.*?)-\>)", "");
File.WriteAlText(path, noComments);


But I have no idea why you would want to remove comments: they are generally there for a very good reason...-->
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900