디렉토리의 파일을 가져오는 것은 Directory.GetFiles()로 할 수 있습니다.
하지만 fullpath로 가져오게 되는데요
디렉토리의 파일명만 가져오는 방법에 대해 포스팅 하겠습니다.
![](http://t1.daumcdn.net/tistory_admin/static/images/xBoxReplace_250.png)
테스트할 폴더를 생성했습니다
![](http://t1.daumcdn.net/tistory_admin/static/images/xBoxReplace_250.png)
![](http://t1.daumcdn.net/tistory_admin/static/images/xBoxReplace_250.png)
String.Join(Environment.NewLine, Directory.GetFiles("C:\RPA\testFolder"))
String.Join(separator, Array)로 다음과 같이 출력할 수 있습니다
![](http://t1.daumcdn.net/tistory_admin/static/images/xBoxReplace_250.png)
![](http://t1.daumcdn.net/tistory_admin/static/images/xBoxReplace_250.png)
String.Join(Environment.NewLine, Directory.GetFiles("C:\RPA\testFolder").Select(Function(a) Path.GetFileName(a)))
Path.GetFileName으로 파일명만 가져올 수 있습니다.
Path.GetFileNameWithoutExtension으로 확장자까지 빼고 가져올 수 있습니다.
종종 쓸모가 있어 포스팅해봅니다.
끝!
'RPA' 카테고리의 다른 글
[UiPath] Duplicate Column (4) | 2023.02.15 |
---|---|
[UiPath] Activate가 안될 때 (3) | 2022.11.16 |
[UiPath] 디렉토리 사이즈 구하기 (0) | 2021.12.16 |
[Zapier] zapier 알아보기 (0) | 2021.11.16 |
[UiPath] String.Format 사용하기 (0) | 2021.07.23 |