可以使用以下代码将文件夹下的所有文件名保存到 aa 中,并排除已经存在的文件:

using System;
using System.Collections.Generic;
using System.IO;

class Program
{
    static void Main()
    {
        string folderPath = "your_folder_path";
        List<string> aa = new List<string>();

        // 添加已存在的文件名到 aa
        aa.AddRange(Directory.GetFiles(folderPath).Select(Path.GetFileName));

        // 添加新的文件名到 aa
        aa.AddRange(Directory.GetFiles(folderPath).Select(Path.GetFileName).Except(aa));

        // 输出 aa 中的文件名
        foreach (string fileName in aa)
        {
            Console.WriteLine(fileName);
        }
    }
}

其中,folderPath 是要检索的文件夹路径。首先,将已存在的文件名添加到 aa 中,然后再将新的文件名添加到 aa 中。最后,使用 foreach 循环输出 aa 中的文件名

c#将文件名保存到aa中类型是Liststring然后检索一个文件夹下面的所有文件名如何排除aa中已经存在的文件