Folder path can’t be accessed

In my workflow, i use path exist first to check if folder is exist or not.
If not exist then stop process.

My question is path exist activity able to check if the folder is can be access or not as well?
Or at least will the path exist activity throw an exception error if the folder can’t be accessed? So i can surround it with try catch and what is the catch type?

@wija

Select folder type in path exists property

Exists is the property which will give you true if exists else false which can later be used in if condition if you want

Cheers

Thank you for reply, but your answer is very basic & already done that.
Please read again my question :pray:

@wija

It wpuld not throw any error if path is not accessible…you would get a true or false only

Cheers

I see, any idea which activity / how to check if the “folder path” is accessible or not?

@wija

You can try using folderinfo activity

Or using system.io.directoryinfo or directory.Accesscontrol will give you information about folder.you can check if it is read only or write or other properties

Ideally if you have minimum read access only then path exists would give you true else it gives false

Cheers

Cheers

In the link of Get folder info activity, doesn’t mention “folder access”, so maybe this activity is not the answer i’m looking for.

And the link of stackoverflow, the idea is to use C# code and put it in invoke code activity.
The code logic is if the folder access at least read only (but in my requirements i need folder that have access read & write) return true else false. And to check the accessibility of the folder, also require code that get the current user identity first.

^ hmm idk this code seems will give new error in the future & is pain in the ass for me :laughing:

And maybe i just got idea that more reliable, i will just use if pathExist = true then “try: activity write file.txt into that folder, if return exception access denied then catch: i don’t know the exception type is”, if not return exception then delete the file.txt (means the folder is accessible read & write isn’t it?).

You know what exception type to catch when return exception folder access denied?
Maybe “System.UnauthorizedAccessException”? Based on this image from google image:
image

@wija

Directory.Accesscontrol is what gives you the details of what kind of access and all…

Yes the exception type is what is shown in the image…System.UnauthorizedAccessException

Alternately to be double sure in catch block you can as well check the error message if it says access denied

Cheers

yes, but i don’t have the object to testing this yet.
I just want to create this kind of validation just to make sure all folder path that the UiPath robot used all not problematic folder path before continue next process steps.

@wija

You can test as well…make some file read only…or if you have multiple users…try checking files on other users folder mostly till you open manually they will be locked…so you can check the same

Cheers

fortunetly i found it:
Untitled

@Anil_G my first test is path exist is still able to found the shared folder (path exist = true), even tho i manually create new folder into the shared folder and resulting destination folder access denied.

so next test try create new file by UiPath robot into that shared folder to see the error exception.

@Anil_G ah, so the exception type is “System.AggregateException” hmm maybe System.UnauthorizedAccessException is for File while System.AggregateException is for folder but my requirement is to check folder so i will just use the catch block System.AggregateException based on my testing.

1 Like

@wija

Aggregateexception was because more than one exception occurred…if that is not the case then the exception type would be different

Just try any wrong folder and check you should get one…for not available as wlel or access not available

Cheers

this weird, for the testing i create new project in UiPath studio & i only put 1 write text file activity that give that error result: Aggregateexception

how come more than one exception occured? well, i’m not sure tho

from this error message: it is says one or more errors occured. But all the errors occured are “access to the path is denied 3times” how come 3 times i only put 1 write text activity LOL

1 Like

Path exists - True or false
use flow decision
Connect true to the part of other sequence and false to write line activity, path does not exist

@Anil_G
in the end i chage my activity from write text file activity to copy file activity and finally get the correct exception type: System.UnauthorizedAccessException
Screenshot 2023-01-14 134758
well in my requirement, there is a template file, will try just copy that template in all folder paths, if return error than send email notif to IT and stop process, else keep continue the process and delete the copied template.

thank you for answer, but this is not about path exist or not, this is about the folder path is accessible or not. Path exist activity only able to check if the path is exist or not.

1 Like

@wija

Thats true…path exists as name suggest is for exusts or not…

Accessibility to the path is different

Cheers