Error when moving files

When using the UnattendedRobot, the following error occurs during the file move process:
Index was outside the bounds of the array.
There is no error when running the same process in debugging mode or when using the AttendedRobot.

UIAutomation.Activities is version 25.10.34
System.Activities is version 26.6.0.

The version for all running environments is 24.10.1.

Hello

I think the contents of FileList might be empty.

I wonder if the right side specification of “Get Full Path of Downloaded Files” isn’t correct. What do you think?

Alternatively, it might be better to use a Wait activity for the download.

I checked the video during the error, and the download was complete.
I set up logging to output FileList(0) during execution with UnattendedRobot, so I plan to check this first.

Hello

I’m wondering if you are looking in the wrong folder. Which folder are you currently checking?

The right side of FileList is set as follows:
System.IO.Directory.GetFiles(DownloadPathValue,“*standard” & YearMonthDate & “WEEKLYxlsx.zip”)

DownloadPathValue is obtained as follows:
DownloadKeyName=“{374DE290-123F-4565-9164-39C4925E467B}”
regKey=Registry.CurrentUser.OpenSubKey(“Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders”)
DownloadPathValue=regKey.GetValue(DownloadKeyName).ToString

By the way, before the file move that causes the error, I am moving another file in the same way, but this one does not result in an error.
System.IO.Directory.GetFiles(DownloadPathValue,“*maximum” & YearMonthDate & “WEEKLYxlsx.zip”)

In that case, should we consider that the naming might not be appropriate?

We should verify whether the expected files actually exist in the relevant folder, and check if they meet the condition of

“*standard” & YearMonthDate & “WEEKLYxlsx.zip”.

Hello

Please let me know two things.

  1. Is the file on SharePoint or in the cloud, rather than local?
  2. Did the file move fail due to the error, or did it succeed?

This is the Edge popup during an error.
The files that meet the conditions are being downloaded.

  1. The file is on the local machine.
  2. The results of the file transfer were not confirmed. It has been recovered, and the state at the time of the error cannot be verified.

To isolate the cause,

first,

fileList=System.IO.Directory.GetFiles(DownloadPathValue)

and then,

output the contents with

String.Join(vbcrLF,fileList)

to check if the expected files are present.

If they are present, it seems that there is some reason why specifying the file name with wildcards is not desirable, so I will investigate that further.
If they are not present, it is likely a problem with the folder specification.

Hi @kana612,

One additional thing I’d check here is the Windows user context, because the difference between Attended and Unattended execution is a very important clue.

You are resolving the Downloads folder through:

Registry.CurrentUser

That means DownloadPathValue can be different depending on which Windows account/profile is running the Robot.

So I would log these values during both Attended and Unattended execution:

Environment.UserName
DownloadPathValue

and also:

String.Join(vbCrLf, System.IO.Directory.GetFiles(DownloadPathValue))

Then check whether the expected standard...WEEKLY...zip file is actually present in the exact folder used by the Unattended Robot.

I would also temporarily avoid FileList(0) and check the count first:

If FileList Is Nothing OrElse FileList.Length = 0 Then
    Throw New Exception("Expected download was not found. Folder: " & DownloadPathValue)
End If

Then use FileList(0) only after confirming that the array contains an item.

There is another thing worth checking in the wildcard itself. Make sure it exactly matches the downloaded filename, including dots. For example, if the real file is:

abc_standard20260908WEEKLY.xlsx.zip

then the pattern needs to match that exact structure.

Given that Attended works but Unattended fails, I’d investigate the Windows user/profile + resolved Downloads path first, before assuming the download itself is failing.

That would also explain why visually checking the download in the browser shows the file successfully downloaded while Directory.GetFiles() in the Unattended execution still returns an empty array.