How to get only filenames within a directory using c#?

后端 未结 7 1679
闹比i
闹比i 2020-12-04 15:05

When I use the line of code as below , I get an string array containing the entire path of the individual files .

private string[] pdfFiles = Directory.GetF         


        
相关标签:
7条回答
  • 2020-12-04 15:56
    string[] fileEntries = Directory.GetFiles(directoryPath);
    
    foreach (var file_name in fileEntries){
        string fileName = file_name.Substring(directoryPath.Length + 1);
        Console.WriteLine(fileName);
    }
    
    0 讨论(0)
提交回复
热议问题