Easily retrieve location of Documents folder

Hi, how do I retrieve the full path of the default Documents folder in Windows?

Knowing that each Windows user has its own Documents folder, also there may be other variables which affect where this folder is located

Assign = Directory.GetFiles(“c:\users
”)

@Jersey_Practical_Sho How do you get the username of the current user?

user = Environment.username

assign = directory.getfiles(“c:\users.
” + user.tostring)

remove the 3 dots and add a backslsh in

Hmm, I just navigated to C:\Users\Username\Documents and my files are not there. It does not point to the same location as the “Documents” quick access shortcut

Any help?

right click the quick link and go to properties and see where the target location is

image

Main.xaml (5.4 KB)

this would work better as it will traverse all sub directories

Directory.GetFiles("C:\Users\"+ user.ToString + "\documents\" , "*.*", searchoption.AllDirectories)

You can use the “Get Environment Folder” Activity using which we can retrieve the path of a list of standard folders like the “My Documents” , Desktop, Program Files etc. Hope this helps.

For your personnal documents folder
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments).tostring
->C:\Users\myName\Documents

For common documents
Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments).tostring
->C:\Users\Public\Documents

cf

For earlier version of uipath you can use the Activity System/Environment/Get Environment Folder
image

2 Likes