Copy files with file length greater than 260 characters

I need to copy a files whose path length is greater than 260 characters. This works fine when you copy it normally through file explorer or cmd or power-shell. But when I try to do this from “Move File” UiPath activity it throws the long file path error. I tried to invoke power-shell and passed the command, but still it throws the same error. Can somebody help me with this?

Hi
Welcome to uipath community
Hope these steps would help you resolve this
—use a assign activity like this where get the file path of all files from a folder which we are going to check with the length of Charta tees and then copy them to another folder
arr_files = Directory.GetFiles(“yourfolderpath”)
Where arr_files is a variable of type array of string

—now use a FOR EACH activity and pass the above variable as input and change the type argument as string in the property panel
—inside the loop use a IF condition like this
item.ToString.Length>260
If true it will go to THEN apart where we can use MOVE File or copy file activity with filepath to be moved as item.ToString and mention the destination folder path

Cheers @stephenmarri

@stephenmarri,

Welcome to UiPath Community!

You can do some best practices to avoid long path issue.

  • Share a subfolder
  • Map a network drive and move the files in it.

I’ve tried your method. The source folder contains two files and one of them has a long file path. The shorter file got moved but facing the below error for the other file.

I cannot proceed with sub folder option, but can you please help me with the “map a network drive” option. Also, initially windows also didn’t allow me to copy files with long file names, then I had to change a registry entry to enable the same. Is there something like that in UiPath that I need to enable for long file paths.

@stephenmarri,

To map network drive refer this link,

We have some third party tools to copy a long file path

I tried to copy the entire folder also.

copy “sourceF[older*” "destFolder"

This command is working fine in power-shell. But when I pass the same through Invoke Power-shell it throws the long file path error. Can you help with a work around for this?

I finally copied the entire folder using the “start process” activity and ran cmd through it.

image

hello

hey use Long Path Tool software

You can try using LongPathTool software. It will help you resolve your specific problems regarding File name too long. Thank you.