How can you write a path that changes for every user?

Hello, I have a process that downloads an excel file from a web page, the problem is that the process is running on multiple virtual machines, so the user name changes everytime.

How can I write the path to get the user?

the path is “C:\Users\RobotDEV\Downloads\File002.xls”

like this
"C:\users"+Environment.UserName +\Downloads\File002.xls"

i.e replace username RobotDEV with Environment.UserName,
Environment.UserName will equal the current username

Thank you. Also can you help me with something similar?

If I search for a file that starts the same but the end different every time how can I do this?

For example the files that I download have the name like this “File_24593”, “File_95832” the ending number is random. How can I search for it just by the “File”

Hello @adrianab.98
If you download the file from Website, Use the Wait Download Activity and the Click activity place inside it (Whick click the Download Button)

Use it for the Monitor folder, It will get Username as dynamic
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)+"\Downloads"
Assign variable for Download file Like DownloadedExcel
You can get the Downloaded file with its name by using DownloadedFile.Fullname

1 Like

Try this

Directory.GetFiles(YourPath,"File*.xls").Count   -->To get the Count of File name start with File. It is an array, you can loop it in usigng For Each
Directory.GetFiles(YourPath,"File*.xls")(0).toString -->to get the 1st File of matched with "File" started nameed Document

1 Like

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