フォルダ内のファイルをすべて削除したいです

フォルダ内のファイルをすべて削除して、フォルダを空にしたいです。

こちらの場合は、 「PowerShellを呼び出し」アクティビティのプロパティ「TypeArgument」で、何を選択すれば良いのでしょうか?

また、こちらの場合は
[入力][DeleteDirectoryOption型]と設定して、「Value」には何を入力すれば良いのでしょうか?

教えてください。
どうぞよろしくおねがいします。

Hi @111561

If you have files within a folder then use the below code in Invoke Code activity

Dim directoryInfo As New System.IO.DirectoryInfo(folderPath)

' Delete all files in the folder
directoryInfo.GetFiles().ToList().ForEach(Sub(file) file.Delete())

If you have sub-folders within a folder then use the below code in Invoke Code activity

Dim directoryInfo As New System.IO.DirectoryInfo(folderPath)

' Delete all files in the folder
directoryInfo.GetFiles().ToList().ForEach(Sub(file) file.Delete())

' Optionally, delete all subdirectories as well
directoryInfo.GetDirectories().ToList().ForEach(Sub(subDir) subDir.Delete(True))

Give the arguments in below way

Hope it helps!!

1 Like

こんにちは

当該フォルダを(再)作成できる権限があるなら、一度そのフォルダをDirectory.Deleteで削除して
フォルダを再作成すると楽かもしれません。

下記の様になると思います。

1 Like

できました!
ありがとうございます。

丁寧に教えていただいたことに感謝します。

1 Like

いつもありがとうございます!
こちらの方法も試してみます。

参考ですが、上記メソッド呼び出しアクティビティ使っていますが、フォルダー削除アクティビティでも動作すると思うので、こちらをお試しいただいた方が良いかもです。

1 Like

ありがとうございます!

「フォルダー削除アクティビティ」は使ったことあります。
フォルダー削除だけでもいろんな方法があるのですね。
それぞれの利点を理解して、使い分けができるようになりたいです。

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