Jhonatan Birdy
Jhonatan Birdy

Reputation: 227

How can i get from a directory string only the file name in the end?

I have a List<string> that contain 5 files for example in index[0] I see:

D:\New folder (45)\converted.avi_Automatic\Lightning 2 Length 4 [276 - 280]\000276.bmp

The line is :

label22.Text = files[_indx].ToString();

I want instead see in label22 : D:\New folder (45)\converted.avi_Automatic\Lightning 2 Length 4 [276 - 280]\000276.bmp to see only: 000276.bmp

Before files were _files wich is a List<FileInfo> so I could make _files[_indx].FullName or .Name

But now the list is List<string>

Upvotes: 1

Views: 71

Answers (1)

nemesv
nemesv

Reputation: 139748

You can use the Path.GetFileName method

label22.Text = Path.GetFileName(files[_indx]);

Upvotes: 6

Related Questions