How to add the file paths into variable seperated by ,

Hi Team,

I keep all the downloaded files in Input folder

i want to read each file from the folder by using for each file

and do some activities in for loop.

next step is i want all the file path into seperate variable seperated by ‘,’

How to get the all files filepaths in single variable seperated with ‘,’

Thanks
Likitha

Hi @vinjam_likitha ,

Could you check the below Expression :

String.Join(",", Directory.GetFiles("Your Folder Path").ToArray)

Hi @vinjam_likitha

Try this:

filePathsArray = Directory.GetFiles("C:\YourFolderPath\Input")
filePaths = String.Join(",", filePathsArray)

Hi

In for each loop i have an if condition based on it i should consider the required files filepath not all the files in the input folder .

i need to add the required files filepath into variable.

Thanks
likitha

@vinjam_likitha ,

In this case, you could use a String variable and add the Iterative Path value to it one by one.

strAllPaths = strAllPaths+","+CurrentItemPath

Make sure to Initialise strAllPaths with Empty String at the beginning.

After the For Each loop end, we could use the below Expression to Trim off unwanted commas :

strAllPaths = strAllPaths.Trim(",".ToCharArray)

@vinjam_likitha

filePaths = New List(Of String)
inside if condition:
filePaths.Add(filePath)

after the loop:Preformatted text
allFilePaths = String.Join(",", filePaths)

Example:
image

Thanks All for solutions

1 Like

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