日期:2014-05-17 浏览次数:20850 次
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] CharNum = new string[] { "一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二" };
            string[] Num = new string[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" };
            DirectoryInfo di = new DirectoryInfo(@"C:\test");
            di.GetFiles().ToList().ForEach(x => 
                {
                    string NewName = x.Name;
                    for (int i = CharNum.GetLength(0) - 1; i >= 0; i--)
                    {
                        NewName = NewName.Replace(CharNum[i], Num[i]);
                    }
                    File.Move(x.FullName, x.Directory + "\\" + NewName);
                });
        }
    }
}
------解决方案--------------------
DirectoryInfo 的说明http://msdn.microsoft.com/zh-cn/library/system.io.directoryinfo(v=vs.80).aspx
帮LZ顶下吧
------解决方案--------------------
文件在读取时  不能同时修改文件名字的吧
被其他进程使用中
------解决方案--------------------
 File.Move()
------解决方案--------------------
现提取最后一个.的后缀
然后自己命名拼接