Store filenames string variable with semi colon

How to iterate throw download folder and store full path of file names and each file name should be separated with semi colon.

Expected data in string variable :

c:\users\testuser\downloads\test.csv;c:\users\testuser\downloads\test2.csv;c:\users\testuser\downloads\test3.csv

Hi @Sathish_Kumar_S,

Try this.

String.Join(“;”,Directory.GetFiles(FolderPath,“*.csv”))

Hope it helps.

1 Like

Hi @Sathish_Kumar_S

You can get all the file names into an array using this:

Directory.GetFiles(FolderPath,“*.csv”)

On this array, you can use a for each loop & add each file name to a string called result:

result = result + filePath + ";"

then, you can trim the last ; by using:

result = result.TrimEnd(";"c)

Hope this helps,
Best Regards.

I want to store all the file names ( full path) separated with semi colon in string variable

Like this :grinning:

Str_Variable = c:\users\testuser\downloads\test.csv;c:\users\testuser\downloads\test2.csv;c:\users\testuser\downloads\test3.csv

Did you try this?

String.Join(“;”,Directory.GetFiles(FolderPath,“*.csv”))

@Sathish_Kumar_S

The result variable holds the result that you want to achieve.

Best Regards.

Hey @Sathish_Kumar_S ,
In order to get the files from “Downloads” you can use this.

Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)+"\Downloads"

U can refer the below workflow
LastrowCOlumn.zip (1.9 KB)

Regards,

1 Like

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