2013-1-1遍历文件夹,改名文件

DirectoryInfo Dir=new DirectoryInfo("D:\\Call of Duty 2\\main\\iwd\\"); //*1

int cnt=0;

foreach(FileInfo f in Dir.GetFiles("*.iwd"))

{

  string cc = f.Name;

  string nc = "";

  for (int i = 0; i < cc.Length-4; i++)

  {

    if ((string.Compare(cc.Substring(i, 1), "a") >= 0 && string.Compare(cc.Substring(i, 1), "Z") <= 0) || (string.Compare(cc.Substring(i, 1), "0") >= 0 && string.Compare(cc.Substring(i, 1), "9") <= 0))

    nc += cc.Substring(i, 1);

  }

  f.MoveTo("D:\\Call of Duty 2\\main\\iwd\\"+nc+".iwd");

  cnt++;

  this.Text = cnt.ToString() + " " + nc;

}

posted on 2016-10-15 19:03  mol1995  阅读(200)  评论(0编辑  收藏  举报

导航