CAN ANYONE HELP HOW TO SAVE Values in the variable

Main (14).xaml (7.7 KB)

CAN ANYONE HELP HOW TO SAVE Values in the variable i want to save all values in different variables

What are you trying to do with the list of files?

i want to pass the path in read csv

Then try read.csv using the “files.tostring” as the file name inside the loop

i am using if condition to check if it contain that type or not as well

@Matt_S how can i convert that into array

@manojv02500 the directory.getfiles() method can use a filter. I would recommend using that filter to get the file types you want rather than retrieving everything and then later using an if statement. See documentation here: Directory.GetFiles Method (System.IO) | Microsoft Learn

Also, it appears as though you are trying to find the first .xaml file only. I would not use a for each loop at all. Instead, you can do it all within a single assign activity like this: assign firstfile = Directory.GetFiles("C:\Users\mv57816\Desktop", "*.xaml")(0)

How this works: This is using the directory.getfiles() method to retrieve all files ending in .xaml found on that specific user’s desktop. The directory.getfiles() method returns an array of strings, so the (0) at the end is retrieving the first element (index = 0) of the string array

2 Likes

in my folder i will have 4 csv files i want read all of them one by one and leave the last sunday file in total 8 files 4 of one type 4 of other

You could get files that do not have Sunday date and then run a loop to remove those files files first, then do another loop to deal with leaving the most recent file for each type.

@manojv02500 - Ok i guess i misunderstood what you were trying to do based on the .xaml you uploaded. So you want to find 4 .csv and 4 .xaml files in a folder? and that folder will have exactly 4 .xaml files, and will have 5 .csv files, correct? You want to avoid the .csv file that was created on the previous Sunday?

Please let me know if all of those assumptions are correct. If they are incorrect, please give me the requirements and constraints and I will help you as best as I can. All of the above should be possible with the .getfiles() method, for each loop, and using each files .directoryinfo to get the .createddate property. I just want to make sure all assumptions are correct

PS To get value from array arrayvariable(# of index). IN this case, since you did not assign the get files statement to a variable so it would be:
Directory.GetFiles(Path)(0).tostring to return 1st file
Directory.GetFiles(Path)(1).tostring to return 2nd file
Directory.GetFiles(Path)(2).tostring to return 3rd file