I am trying to count the files in a folder, I retrieve the folder path using the following assign:
Folder path = (MainDictionary(“MainFolder”).tostring+Now.ToString(“yyyy”)+" \ “+StrConv((now.ToString(“MMMM”, System.Globalization.CultureInfo.CreateSpecificCulture(“es”)).ToString).ToLower, VbStrConv.ProperCase)+” \ ").Trim
The result is: "C:\TestFolder\2022\Abril"
But it fails while trying to reach that folder.
BUT, if I assign the SAME string in inmediate: "C:\TestFolder\2022\Abril"
It works. Look in the screenshot below immediate panel and the output and you will see it works, I do not know what is happening
I tried with a replace for the character " \ " using the same as inmmediate: FolderPath.replace(" \ “c,” \ ") in another assign
And here it is the writeline value: Directory.GetFiles(FolderPath).Count.ToString
1 Like
Hey @Alberto_Palma
Could you please try printing it before write line.
Also try path.Join
instead of string concatenation for cleaner approach.
Thanks
#nK
1 Like
Nithinkrishna:
path.Join
Thank you for the answer, Here is the print before:
How should I use the path join? I am having difficult to find the way to use it.
1 Like
Hey @Alberto_Palma
Could you please post the Directory.GetFiles
you are using.
Sorry It’s not path.Join
instead path.Combine
Path.Combine(MainDictionary(“MainFolder”).tostring+Now.ToString(“yyyy”), StrConv((now.ToString(“MMMM”, System.Globalization.CultureInfo.CreateSpecificCulture(“es”)).ToString).ToLower, VbStrConv.ProperCase))
Thanks
#nK
1 Like
Thanks again.
I used your code, but:
The directory I am using is this one: Directory.GetFiles(FolderPath).Count.ToString
1 Like
Hey @Alberto_Palma
Could you please hard code the path once inside the directory function once please to troubleshoot?
Thanks
#nK
1 Like
I solved it using a Array of string variable to store the “Directory.GetFiles(FolderPath)” result, and it works without issues, I do not know why it happens, but it solves the code.
Thank you for your time and effort Nithin!
1 Like
system
(system)
Closed
April 10, 2022, 7:49am
9
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.