Hi Guys
I am looping through a Directory(folder1) and inside that directory, I have few files (fil1.txt, file2.txt, file3.txt…).
is there any way to push all files to a single string(file1.txt, file2.txt, file3.txt…)?
Hi,
In the loop you can read the text file using read text file activity and store the output of the activity in some variable say strFileContent
after reading text file use assign activity in left hand side use strFullFileContent and on right side of assign activity use strFullFileContent+strFileContent
so after the loop you will have content from all the files in a single variable strFullFileContent
Yes. It is Possible. Just Do the below step :-
1st of all you must be getting all the files in a String Array by using below statement right ??
ArrayOfString FilesInDirectory[] = Directory.GetFiles(path)
So take assign activity
String var = String.Join(",",ArrayOfStringVariable)
i.e by my eg it will be FilesInDirectory
This will assign all the file names into a single String Variable
Mark as solution and like it if this helps you
Happy Automation
Best Regards
Er Pratik Wavhal
Hi,
If you want to writhe file names in a string,
- Take an empty string (Ex: FilenameStringVal = “”)
- In the directory loop get the file names with extension (file1.txt, File2.txt etc…)
- Concatinate the file names in the empty string (FilenameStringVal = FilenameStringVal+", "+filename.txt)
Try the above steps and let me know if any doubts.
Mark as solution if it works
I don’t want to read the files content inside the folder, i need only file path
Let’s assume i have a directory called “MainDirectory”, inside the directory i have few attachments and the paths are (“D:\MainDirectory\Test1.PNG”, “D:\MainDirectory\Test2.PNG” …) etc.
After Putting the “MainDirectory” in a for each loop it’s giving me the file path one by one, so i want to put all the attachment path in one single string like
allPaths = D:\MainDirectory\Test1.PNG D:\MainDirectory\Test2.PNG…
Try the approach that i have given by using
String.Join(",",Directory.GetFiles("D:\MainDirectory"))
Mark as solution and like it if this helps you
Happy Automation
Best Regards
Er Pratik Wavhal
This is exactly what i wanted.
Dude you are awesome, Thanks.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.