Hi all,
I have an issue need your kind help.
I define one array as below type:
After that, I get all files from one folder to this array using: Directory.GetFiles(FilePath, ā. ā,SearchOption.AllDirectories)
Now I want to use for each to loop the array and then move some items to another array if the condition met:
but it does not work, please suggest where is the problem?
thanks a lot
Michael
@Michael_zhao What kind of condition should be meet here?
if the data size of the file is more than 20MB.
thanks a lot for your reply
@Michael_zhao Here is your solution. Check the below-attached workflow
Dummy.xaml (6.7 KB)
I hope this will help you
Regards,
Vrushali
Hi @Michael_zhao
Have a look to below thread. I think might your query is somewhat similar to below thread :-
Hi @413387330
As per me below workflow steps should work :-
Files array will be der in ForEach Activity
I have attached the workflow which will give the file size in MB
After measuring Each file size Just check within If Activity as fileSizeInMB <= 10
If Yes then create the New List & repeat the loop and add the next file in New List which will consists of the files having size less than 10MB along with that add the file Size also till it gets 10MB to the same variable fileSizeInMB or you cā¦
Happy Automation
Best Regards
Er Pratik Wavhal
Hi,
thanks a lot for your solution.
I saw you move the file to one folder, but i need to append it to another array in the loop, and finally i will send it out by email with the file array .
thanks a lot, Pratik
The challenge for me is how to move the value from one array to another array in the loop.
Hi @Michael_zhao
1st of all array is a collection and is of static size so you should use List<> instead of Array for moving the items.
And also you can do many operations on List same as Array.
Below is the Workflow for moving Array Items to List :-
MainPratik.xaml (9.0 KB)
Mark as solution and like it if this helps you
Happy Automation
Best Regards
Er Pratik Wavhal
Hi Pratik,
It seems works very very fine .
I can also send it out by mail with file list after moving .
thanks a lot.
Michael
By the way, could you please let me know how to clear the list and how to check if it is empty?
assign nothing to list can clear it?
using if the list is nothing can know if it is empty, right ?
thanks very much .
J0ska
August 12, 2020, 9:09am
11
You could use following expression to get just files over 1MB
FileCol = Directory.GetFiles(FilePath,".",SearchOption.AllDirectories).Where(Function(x) (New FileInfo(x)).Length > 1024000).ToArray
Cheers
Hi @Michael_zhao
Der is Clear Collection Activity to clear the List
If you want to check If List is empty or not then below is the condition for the same you can put in IF Activity :-
listOfFiles.Count=-1
Happy Automation
Best Regards
Er Pratik Wavhal
system
(system)
Closed
August 15, 2020, 9:10am
13
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.