web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to use variables i...
Power Automate
Answered

How to use variables inside file paths

(1) ShareShare
ReportReport
Posted on by 31

I've created a variable storing the profile username and I want to reference the variable inside of a file path, but I'm getting an error message. When I hard-code the profile username into the file path the file opens successfully. I realized it's because the file path is line breaking after the variable, is there a way to fix this so I can include the variable inside the file path?

 

File path: C:\Users\%variable%\Downloads

 

Error message: Illegal characters in path.: Microsoft.PowerPlatform.PowerAutomate.Desktop.Actions.SDK.ActionException: Failed to read text from file C:\Users\sesa0000
\Downloads ---> System.ArgumentException: Illegal characters in path.

Categories:
  • trice602 Profile Picture
    16,595 Super User 2026 Season 2 on at

    Hi @tgut03 ,

     

    This looks correct.  The way to make this work is to put that into a compose action, and create your dynamic file path there.  Then when you refer to the path, you refer to the output of the compose action.

     

     

  • Verified answer
    tgut03 Profile Picture
    31 on at

    Use the get windows environment variable action and select username. Set the variable equal to the environment variable value and the file path opens successfully. 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 231 Super User 2026 Season 2

#2
David_MA Profile Picture

David_MA 217 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 170

Last 30 days Overall leaderboard