C#中我想获取某个文件夹下面的xml文件个数,代码怎么写!求高手指导,谢谢!!

发布网友 发布时间:2022-04-26 21:30

我来回答

1个回答

热心网友 时间:2023-11-05 03:27

using System;
using System.IO;
namespace FilesDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            DirectoryInfo directory = new DirectoryInfo("D:\\");
            FileInfo[] files = directory.GetFiles("*.xml");
            //输出文件个数
            Console.WriteLine("Files Number:{0}", files.Length);
            //遍历文件
            foreach (FileInfo file in files) {
                Console.WriteLine(file.Name);
            }
            Console.ReadKey();
        }
    }
}

热心网友 时间:2023-11-05 03:27

using System;
using System.IO;
namespace FilesDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            DirectoryInfo directory = new DirectoryInfo("D:\\");
            FileInfo[] files = directory.GetFiles("*.xml");
            //输出文件个数
            Console.WriteLine("Files Number:{0}", files.Length);
            //遍历文件
            foreach (FileInfo file in files) {
                Console.WriteLine(file.Name);
            }
            Console.ReadKey();
        }
    }
}

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com