Need help working with long paths

Hey!

I’m working on a solution that lists folders and files of a given folder. Sometimes a given folder has such a complex and deep structure that a PathTooLongException occurs (maximum 260 characters or 248 for directories). Unfortunately I may not rename files or folders to reduce path length. In fact, I don’t have any influence on given folders. I just have to deal with the long paths.

I tried

  • researching the problem in UiPath Forum, but most answers are bots praising long path tool - doesn’t fit my requirement
  • an alternate way to get paths with PowerShell script instead of VB .Net - same error!
  • Using the \\?\ prefix to use Windows API without path length limit (i think?), but now characters in the path (e.g. dots (.)) are invalid :face_with_raised_eyebrow:
  • Setting RegistryKey for LongPathEnabled as described here, but I didn’t get the application manifest part and it didn’t work on its own - do I have to edit Studio.manifest?!

I also stumbled upon the ExtendedFileInfo library that looks like it could help, but sadly I am clueless how to implement this into my UiPath flow.

Any help is greatly appreciated!
Cheers

1 Like

Do you guys have an idea? @vvaidya @ClaytonM @bcorrea

Thanks for your time!

Maybe this will help, if you really have paths bigger than 260:

2 Likes

I’m not really sure because I haven’t dealt with the longfilepath issue since earlier versions of Windows, but that link provided by bcorrea has some good info. You may need to set the currentdirectory then use the relative path in order to shorten.

1 Like

Thank you for the input!

@bcorrea I really do have paths longer than 260 characters, @ClaytonM even when I use the relative paths. The given folder structure is really stupifyingly complex.

I read up on the Microsoft documentation and actually tried the thing with the registry key:

Can you make sense of the application manifest part?