convert a FileInfo array into a String array C#

前端 未结 4 1162
春和景丽
春和景丽 2021-01-05 05:17

I create a FileInfo array like this

 try
            {
                DirectoryInfo Dir = new DirectoryInfo(DirPath);
                FileInfo[] FileList =          


        
4条回答
  •  死守一世寂寞
    2021-01-05 06:07

    Using LINQ:

    FileList.Select(f => f.FullName).ToArray();
    

    Alternatively, using Directory you can get filenames directly.

    string[] fileList = Directory.GetFiles(DirPath, "*.*", 
                                           SearchOption.AllDirectories);
    

提交回复
热议问题