Hello,
The workflow automates report creation and downloads the report. However, the report comes from the system with a default naming convention. I need to rename the file to the item searched.
The issue I am having is in selecting the most recent file from my downloads folder to rename. I have tried other methods posted here with no success.
I am assigning the most recent file modified in the downloads folder to a temporary string variable. Then renaming the file with the item being used in the loop iteration.
strFileNameTemp = String.Join(“”, Directory.GetFiles(strDownloads,”*.xlsx”,SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Take(1) )
Everytime I run this program I get an error on rename file activity.
**Runtime Execution error: 21.10.7+Branch.support-v21.10.Sha.4fc9759469a976c6aff9aff581b459a31fa01cd9
Source: Rename File
Message: Could not find a part of the path.
Exception Type: System.IO.DirectoryNotFoundException
RemoteException wrapping System.IO.DirectoryNotFoundException: Could not find a part of the path.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.__Error.WinIOError()
at System.IO.FileInfo.MoveTo(String destFileName)
at UiPath.Core.Activities.RenameFileX.<>c__DisplayClass12_0.b__1()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at UiPath.Core.Activities.RenameFileX.d__12.MoveNext()
— End of stack trace from previous location where exception was thrown —
at UiPath.Shared.Activities.AsyncTaskCodeActivityImplementation.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at UiPath.Shared.Activities.AsyncTaskCodeActivity.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
**