2013-01-16 6 views
-4

코드 :디렉토리의 문자열에서 파일 이름 만 가져올 수있는 방법은 무엇입니까?

'파일'은 List<string>이고 _indx는 int입니다.

D:\New folder (45)\converted.avi_Automatic\Lightning 0 Length 2 [91 - 93]\000091.bmp 

하지만 그 대신 label22.Text에 나는 그것이 나머지없는 날은 '000091.bmp'을 보여주고 싶은 : index[0]에서 '파일'의 예를 들어

label22.Text = files[_indx]; 

나는이 문자열을 가지고 디렉토리 경로.

어떻게하면됩니까?

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

코드를 게시하십시오. – Brian

+0

'Google 검색'을 사용하면이 답변을 매우 쉽게 찾을 수있었습니다. http://msdn.microsoft.com/en-us/library/system.io.path.getfilename.aspx – MethodMan

+0

[ C#의 경로 문자열] (http://stackoverflow.com/questions/6921105/get-file-name-from-a-path-string-in-c-sharp) –

답변

1

나는 당신이 Path.GetFileName() 찾고있는 생각

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

가장 간단한 방법은 디렉토리없이

Path.GetFileName(files[_indx]); 
관련 문제