GetFiles - Length error for Assign Activity

Hi, I’m attempting to retrieve files from an online directory using:
Assign: arrFileNames = directory.GetFiles(strDirectory)

I have tried several different directories but constantly receive the following error:
Assign: The specified path, file name, or both are too long. The fully qualified file name must be less that 260 characters and the directory name muse be less that 248 characters.

I have checked the character count of both.
The fully qualified file name is 186 characters (less than 260)
The directory name is 157 characters (less than 248)

I have no idea why this Error message keeps displaying when neither of the counts exceeds the set limits. If anyone has encountered this issue before and has a solution, I would be grateful for any assistance.

Can you test it against a directory on your local computer? It is possible that the length of full directory name & file name exceeds 260 characters.

Hi, thanks for your reply.

I have tested it using a local directory and it works perfectly.
I’ve even tested it with longer local directory path+filenames and it works.
I’ve also tested with shorter online directories and still get the ‘Length’ error.
I’ve also pasted the online directory into a Windows file explorer and the directory has been located without issue, and the contests displayed correctly.

I’m wondering if the error is being displayed incorrectly but haven’t been able to find any information regarding the GetFiles module working with online directories.

I don’t see why studio would care if the address starts with "C:" or "http:" but it might

Hello @danny.vardanega

Can you share the screenshot of the online directory which you are using?

Also what are the values in the variable “strDirectory” ?

As per my understanding this can be helpful for local directories and not online directories.

Can you use Message Box to show the path of a file name? It is likely that the network drive path is super long.

HI and thanks for your reply. Sorry for my delayed response, I was on leave for a few weeks. Here are the details that you requested:

Assign strFileNames = Directory.GetFiles(strDirectory)

strDirectory = “https://oursites.internal.dept.local/communities/Service Delivery Operations Group/Onboarding/Lists/Onboarding Master List 12345/Attachments/1234”

So the strDirectory is 145 characters long. None of the filenames in that directory are more than 100 characters long, so everything is within the parameters

When I use a Log Message or Message Box for strDirectory it displays: “https://oursites.internal.dept.local/communities/Service Delivery Operations Group/Onboarding/Lists/Onboarding Master List 12345/Attachments/1234”

When I paste “https://oursites.internal.dept.local/communities/Service Delivery Operations Group/Onboarding/Lists/Onboarding Master List 12345/Attachments/1234” into windows explorer, it opens the directory correctly and only replaces the special characters like spaces with the correct codes. So it presents as “https://oursites.internal.dept.local/communities/Service%20Delivery%20Operations%20Group/Onboarding/Lists/Onboarding%20Master%20List%2012345/Attachments/1234” which is still only 157 characters

If the issue is that the Directory.GetFiles can only be used for local files, does anyone know of another UiPath element that does work for online directories?

I can use a message box to display strDirectory as follows:
https://oursites.internal.dept.local/communities/Service Delivery Operations Group/Onboarding/Lists/Onboarding Master List 12345/Attachments/1234”

When I attempt to use a message box to display Directory.GetFiles(strDirectory).toString OR attempt to Assign arrFileNames = Directory.GetFiles(strDirectory) I get the same error message:
“The specified path, file name, or both are too long. The fully qualified file name must be less that 260 characters and the directory name muse be less that 248 characters.”

Your URL is not a directory and hence I don’t think you can get the list of file names based on the URL.

Hi everyone, thanks for all of your help.

Just a quick update for anyone else who may have encounter a similar issue:
I was trying to obtain a list of file names that were attached to a Sharepoint list and saved at the URL listed in previous posts. As UiPath doesn’t see SharePoint directories the same as Network directories I had to download the “UiPathTeam.SharePoint.Activities” package which contained an activity called “Get List Item Attachments” which did exactly what I was trying to do and solved my issue

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