# 指定フォルダパスの配下にサブフォルダがあり、その配下のファイル一覧をlist変数lis\_Pathに取得する構文

**URL:** <https://forum.uipath.com/t/list-lis-path/576146>\
**Category:** フォーラム\
**Created:** [Ağustos 28, 2023, 7:32öö UTC](https://forum.uipath.com/t/list-lis-path/576146 "2023-08-28T07:32:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gorby](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/gorby/32/543563_2.png) [@gorby](https://forum.uipath.com/u/gorby)\
**Post date:** [Ağustos 28, 2023, 7:32öö UTC](https://forum.uipath.com/t/list-lis-path/576146/1 "2023-08-28T07:32:49Z")

</div>

こんにちは。UiPath Studio EnterPrise版23.4.2ユーザの初心者です。

指定フォルダパスのファイル一覧をlist変数lis\_Pathに取得する構文は  
lis\_Path=System.IO.Directory.GetFiles(指定フォルダパス).ToList  
であることを知っておりますが、

指定フォルダパスの配下にサブフォルダがあり、その配下のファイル一覧をlist変数lis\_Pathに取得する構文をご存じの方、ご教示ください。

---

<div class="post-metadata">

**Author:** ![mkankatala](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/mkankatala/32/484097_2.png) [@mkankatala](https://forum.uipath.com/u/mkankatala)\
**Post date:** [Ağustos 28, 2023, 7:36öö UTC](https://forum.uipath.com/t/list-lis-path/576146/2 "2023-08-28T07:36:56Z")

</div>

Hi @gorby

Use the below expression

```auto
Directory.GetFiles("your_folder_path", "*.*", SearchOption.AllDirectories).ToList()

```

1. Directory.GetFiles: This is a method from the `System.IO` namespace that retrieves an array of file names in a specified directory that match a certain search pattern.
2. “your\_folder\_path”: Replace this with the actual path of the folder you want to search in. For example, if your folder is located at C:\MyFolder, you would replace “your\_folder\_path” with “C:\MyFolder”.
3. “_._”: This is the search pattern used to match all files. The first \* matches any file name, and the second \* matches any file extension.
4. SearchOption.AllDirectories: This parameter makes sure that files from all subdirectories are included in the search. This is necessary to get files from subfolders as well.
5. .ToList(): This converts the array of file names returned by Directory.GetFiles into a List.

Hope it helps!!

---

<div class="post-metadata">

**Author:** ![Parvathy](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/parvathy/32/484539_2.png) [@Parvathy](https://forum.uipath.com/u/Parvathy)\
**Post date:** [Ağustos 28, 2023, 7:43öö UTC](https://forum.uipath.com/t/list-lis-path/576146/3 "2023-08-28T07:43:01Z")

</div>

Hi @gorby

Try this:

```auto
Assign Activity:
Variable: lis_Path (List<String>)
Value: Directory.GetFiles("specified folder path", "*", SearchOption.AllDirectories).ToList

```

In this syntax:

- Replace `"specified folder path"` with the actual path of the folder you want to search in.
- `"*"` is used as the search pattern, which means all files will be included. You can modify this pattern to filter files based on a specific file extension or name pattern.
- `SearchOption.AllDirectories` ensures that files from all subdirectories are included.

Hope it helps!!  
Regards

---

<div class="post-metadata">

**Author:** ![Shiva\_Nikhil](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/shiva_nikhil/32/267408_2.png) [@Shiva\_Nikhil](https://forum.uipath.com/u/Shiva_Nikhil)\
**Post date:** [Ağustos 28, 2023, 7:50öö UTC](https://forum.uipath.com/t/list-lis-path/576146/4 "2023-08-28T07:50:42Z")

</div>

@gorby

サブフォルダーからファイルを取得するアクティビティごとに、内部のアクティビティごとに別の 1 つを使用します。

これは、メインフォルダー内に多数のサブフォルダーがある場合に便利です。

またはフォルダーアクティビティ内の各ファイルに使用します

 ![image](https://global.discourse-cdn.com/uipath/original/4X/6/2/9/629fd66b379b9597ab9188ac2d0d603910b14315.png)

フォルダーオプションでメインフォルダーのパスを直接渡します

cheers

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [Ağustos 31, 2023, 7:51öö UTC](https://forum.uipath.com/t/list-lis-path/576146/5 "2023-08-31T07:51:27Z")

</div>

Kapattı, Ağustos 31, 2023, 7:51öö UTC tarihinde

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
