How to get file names from the directory, not the entire path

后端 未结 4 617
别跟我提以往
别跟我提以往 2020-12-09 08:51

I am using the below method to get the file names. But it returns the entire path and I don\'t want to get the entire path. I want only file names, not the entire path.

4条回答
  •  春和景丽
    2020-12-09 09:13

    You could use the GetFileName method to extract only the filename without a path:

    string filenameWithoutPath = Path.GetFileName(filename);
    

提交回复
热议问题