How to "dynamically" reference a downloaded excel file of its folder path?

Hi Guys,
As the title entails, I have successfully saved an excel file.
I want to then read it and store it in a DT.

I’m facing challenge on how to reference this folder path dynamically.
My understanding is sometimes when clicking “save” a file button, the default destination can sometimes be on Download folder or Desktop.
Even if I designed the folder path for the download to under Download folder, the name of the pc would be different for each user (see ss2).

I’m intending that this project to be used for someone else (not just me) and hence the need for it to be dynamic.

If you can help to provide some workarounds. Cheers!

ss1:

ss2:

Hello

You can use this to dynamically reference the username and the subsequent folders:

Use an assign to capture the following information into string variables:
str_Username = Environment.UserName
str_Filename = 'Your_TempFile.xlsx" (or whatever you want)
str_Full_Path = “C:\Users"+str_Username+”\Downloads"+str_Filename

Then try typing into the save location field:
str_Full_Path

Hopefully this helps :blush:

Cheers

Steve

Hi @Dillon_Marius

In that case you can a drive which is common for all or if you are saving it in downloads you can try giving below way

"C:\Users\"+Environment.UserName+"\Downloads\file_.xlsx"

Best suggestion would be a common drive present in everyone’s machine. The structure would be like below.

"C:\Users\file_.xlsx"

Hope it helps

Hi @Dillon_Marius

Use below one
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)+“\Downloads”

Hope it will helps you :slight_smile:
Cheers!!

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