UiPath フォルダ内のファイルパス一覧を取得

フォルダ内に存在するファイルパスの一覧を取得したい

フォルダ内に存在するファイルパスを取得したい時にどうすればいいでしょうか?For Eachアクティビティや代入アクティビティを駆使して取得することが可能です。

今回はプロジェクトフォルダ内に「Data\都道府県別」というディレクトリが存在するとします。この中にある都道府県名のついたExcelをそれぞれ以下のように出力するにはどうすればいいでしょうか?

UiPath ワークフローの概要

各代入アクティビティの詳細

Dir = ("フォルダのパス")
FilePathArr = System.IO.Directory.GetFiles(Dir)

UiPathのワークフローの解説

フォルダのことを別名「ディレクトリ」と呼びます。ここでは変数「Dir(ディレクトリ)」をフォルダパスとして設定することで、次の文字列型配列の変数「FilePathArr」ではフォルダ内のパスをすべて取得するSystem.IO.Directory.GetFilesを使用しています。こうすることで、FilePathArrに各パスが取得されます。

ここで注意しておきたいのがFilePathArryの変数の型です。普通のString型ではなく、配列型のString[]になっていることに注意してください。配列型にすることでひとつの変数の中に複数の文字列を代入することができます。

最後に

最後に、For EachでFilePathArrの中をループ処理させることでFilePathをすべて出力することができました。このようにしてUiPathではフォルダパスのファイルの一覧を取得することができます。

是非、活用してみてください。

32件のフィードバック

  1. hey there and thank you for your information – I have certainly picked up anything new from right here.
    I did however expertise several technical points using this site, since I experienced to
    reload the site a lot of times previous to I could get it to load correctly.

    I had been wondering if your web hosting is OK? Not that I am complaining, but
    slow loading instances times will very frequently affect your placement in google
    and can damage your quality score if advertising and marketing with Adwords.
    Anyway I’m adding this RSS to my email and can look out for a lot more of
    your respective intriguing content. Make sure you update this again very soon..

    Escape room

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

目次