RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
c#遍历文件夹下所有文件并更改文件名
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.IO.IsolatedStorage;
namespace 更改文件名
{
    class Program
    {
        static void Main(string[] args)
        {
            string path = @"D:\vs2012\测试ierp\ierp-2\Web";
            DirectoryInfo TheFolder = new DirectoryInfo(path);
            foreach (FileInfo item in TheFolder.GetFiles())
            {
                string name = item.Name;
                if (name.Contains("_"))
                {
                   string xnm= name.Replace("_","-");
                   string xingname = path + "\\转换后的文件\\" + xnm;
                   item.MoveTo(xingname);
                }
                else
                {
                    string xingname = path + "\\转换后的文件\\" + name;
                    item.MoveTo(xingname);
                }
            }
        }
    }
}

文章题目:c#遍历文件夹下所有文件并更改文件名
网站链接:http://sczitong.cn/article/ieidsj.html