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?
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
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
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:
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.
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
@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.
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
@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
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.