Could not find a part of the path (System.IO.DirectoryNotFoundException)

Hi,

I’ve made a process that downloads a few files via Google Chrome and I want it to wait for them to finish downloading before attempting to move them. Chrome has an SQLite file, which stores information such as download history and is located here: %LocalAppData%\Google\Chrome\User Data\Default\History. When UiPath executes the Copy File activity, it throws an error saying that it couldn’t find a part of the path specified. However, I know for a fact that the path exists (I even plugged the following command into a cmd to confirm it: cd "C:\Users\sde\AppData\Local\Google\Chrome\User Data\Default").

Note: Screenshots have been slightly modified to fit all relevant information.

UiPath.Core.Activities.CopyFile

Copy File - History

From

Path.Combine(Environment.GetEnvironmentVariable("LocalAppData"), "Google\Chrome\User Data\Default\History")

To

Path.Combine(Path.GetTempPath(), "UiPath - Special Minds Kolding\History.sqlite")

Runtime execution error

![Runtime execution error](upload://j0wsBhVIADrno6nXAyKDneyMTUE.png)

Sorry, I could only post one link and one image because I’m a new user on the UiPath Forum… Maybe you can still view the image here?: https://discourse-cloud-file-uploads.s3.dualstack.us-west-2.amazonaws.com/uipath/original/3X/8/5/853874e4d7f590b01fe84e29b7c6660f0258e2b4.png

:cry:

Source

Copy File - History

Message

Could not find a part of the path ‘C:\Users\sde\AppData\Local\Google\Chrome\User Data\Default\History’.

Exception Type

System.IO.DirectoryNotFoundException

Details

RemoteException wrapping System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\sde\AppData\Local\Google\Chrome\User Data\Default\History'. 
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost)
   at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite)
   at UiPath.Core.Activities.CopyFile.Execute(CodeActivityContext context)
   at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
   at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
   at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

Execution Log

If for whatever reason you need a look at the execution log, here are the relevant lines:

14:05:07.2538 Info {"message":"Special Minds Kolding execution started","level":"Information","logType":"Default","timeStamp":"2020-03-04T14:05:07.2478895+01:00","fingerprint":"386d410b-102d-40db-ac6c-cb70ae43a0b3","windowsIdentity":"SPECIALIST\\sde","machineName":"SPMINDS-0319","processName":"Special Minds Kolding","processVersion":"1.0.0","jobId":"28296ed1-514f-4247-b88c-b875d2d032b7","robotName":"SPECIALIST\\SDE","machineId":0,"fileName":"Main"}
14:05:52.0783 Error {"message":"Copy File - History: Could not find a part of the path 'C:\\Users\\sde\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\History'.","level":"Error","logType":"Default","timeStamp":"2020-03-04T14:05:52.0783902+01:00","fingerprint":"474a3af5-91f5-4a2d-8904-78494b84f8c5","windowsIdentity":"SPECIALIST\\sde","machineName":"SPMINDS-0319","processName":"Special Minds Kolding","processVersion":"1.0.0","jobId":"28296ed1-514f-4247-b88c-b875d2d032b7","robotName":"SPECIALIST\\SDE","machineId":0,"fileName":"Main"}
14:05:52.0973 Info {"message":"Special Minds Kolding execution ended","level":"Information","logType":"Default","timeStamp":"2020-03-04T14:05:52.0963947+01:00","fingerprint":"6f540bbf-0b6b-4db6-80c9-5ad89e5ef183","windowsIdentity":"SPECIALIST\\sde","machineName":"SPMINDS-0319","processName":"Special Minds Kolding","processVersion":"1.0.0","jobId":"28296ed1-514f-4247-b88c-b875d2d032b7","robotName":"SPECIALIST\\SDE","machineId":0,"totalExecutionTimeInSeconds":44,"totalExecutionTime":"00:00:44","fileName":"Main"}

What else I’ve tried

If anyone knows/finds a solution, I’d highly appreciate if you’d post it below.

Thanks,
Samuel

Hi,
Same code is working for me.
only if chrome is closed .
:+1:

2 Likes

@Debakanta_Mahanta’s solution works and I recommend using it if possible. :confetti_ball:

I do want to add that you don’t necessarily have to close Chrome, even though I recommend that you do if it doesn’t need to stay open, as it would make your process more stable. I think the reason I couldn’t copy the file was because Chrome was writing it. :slight_smile:

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