I currently building an automation that needs to access a folder located on a network drive, however I cannot hardcode this folder path because it may change based on the user running the bot. Need maximum compatibility here.
For example the full folder path is “R:\MainFolder\MyFolder\Teamfolder\BOTFolder”
However, not all members will have the R drive selected, but maybe the S drive(“S:\MainFolder\MyFolder\Teamfolder\BOTFolder”)
The contents I need will always be in the BOTFolder located on the network
Is there an easy way to grab this location without hardcoding the full folder path so that anybody who runs the bot can access the contents?
Before accessing the folder, you can check the existence of directory by using the VB command Directory.Exists() method. If Directory.Exists(“R:\MainFolder\MyFolder\Teamfolder\BOTFolder”), then go for R drive, else you can access S drive
If you know which users have R drive, then you can use the VB command Environment.Username to know the currently logged on user. If username matches with your users list, then use R drive, else use S drive