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

(0) 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\sesa758156
\Downloads ---> System.ArgumentException: Illegal characters in path.

Screenshot 2024-06-21 112538.png
Screenshot 2024-06-21 114208.png
  • 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. 

  • NathanAlvares24 Profile Picture
    1,714 Moderator on at

    .

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

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