Highlighted
Visitor.
76 views

How to detect if there is files in a window directory

Hi,

Is there a way that I can check if there are files inside a directory. If I have to use List Iterator operation, I have to manually hard-code list of file names. I still haven't succeed with hard-code list, anyway. I am exploring option not to have hard-code list.

Thanks you in advance.

Regards,

joe

0 Likes
2 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: How to detect if there is files in a window directory

There are multiple ways to do this obviously.

Strictly using OO operations you can  go for the option  of Get children from path to see if there is anything in the directory  and then iterate / multi instance through the list to see if there are files in that directory. Everything done utilizing the results of the operations, no hardcoded values required.

For directories which contain a lot of  files and folders this may take a long time and  be quite inefficient. 

If powershell usage is available you could simply query powershell for the list of files in the directory. For example see the following command: "Get-ChildItem -Path C:\Temp\Workspace -Recurse –File" which you can trigger through the powershell command operation.

Hope this helps,

Vlad

 

0 Likes
Highlighted
Visitor.

Re: How to detect if there is files in a window directory

Thanks for sharing your idea. Do you have any sample code that can share with me. New to OO and still struggling to digest it. 

 

Thanks,

joe

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.