开发者

Visual Studio plugin to automatically insert comments at the top of every file?

I would like to insert copyright notices as comment blocks at the top of every single source code file in a solution (there's too many files to do by hand). Is there a plugin that will au开发者_开发知识库tomatically do this for me?


You could write a small console app in about 20 lines to loop through every *.cs file and append it to the top....

Perhaps something like this: (Needs Tests)

    public void AddComments() {
       foreach (var file in Directory.GetFiles("C:\\files\\", "*.cs", SearchOption.AllDirectories)){
        StreamReader sr = new StreamReader(file);
        string text = "My Comments" + sr.ReadToEnd();
        sr.Close();

        StreamWriter sw = new StreamWriter(file, false);
        sw.Write(text);
        sw.Close();
      }
   }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜