Seasons.NET

ちょっとした技術ブログです

.svnディレクトリを消す

指定したディレクトリ内の.svnを全て抹消するツール

 1 namespace RemoveSVN
 2 {
 3     using System.Collections.Generic;
 4     using System.IO;
 5     using System.Text.RegularExpressions;
 6 
 7     internal class Program
 8     {
 9         private static List<string> deletePaths = new List<string>();
10 
11         private static void Main(string[] args)
12         {
13             if( args.Length != 1 )
14                 return;
15             if( Directory.Exists(args[0]) )
16             {
17                 DeleteDir(new DirectoryInfo(args[0]));
18                 deletePaths.ForEach(delegate(string path) { Directory.Delete(path,true); });
19             }
20         }
21 
22         /// <summary>
23         /// .svnディレクトリのリストを返す
24         /// </summary>
25         /// <param name="di"></param>
26         private static void DeleteDir(DirectoryInfo di)
27         {
28             foreach(DirectoryInfo dif in di.GetDirectories())
29             {
30                 Match m = Regex.Match(dif.FullName,@".+\.svn$");
31                 if(m.Success)
32                     deletePaths.Add(dif.FullName);
33 
34                 DeleteDir(dif);
35             }
36         }
37     }
38 }