Skip to main content
Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Illegal characters in path

(0) ShareShare
ReportReport
Posted on by 10

Im trying to build a flow to delete files older than 550 days, but i cannot seem to even get it to delete a test file from a test folder with no conditions.

 

Get files in folder - output to variable "Files"

Delete Files - "Files"

 

Microsoft.Flow.RPA.Desktop.Modules.SDK.ActionException:

Can't delete file C:\Users\james\Desktop\Data FolderC:\Users\james\Desktop\DataFolder\76543.txt ---> System.ArgumentException: Illegal characters in path.
at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)
at System.IO.Path.GetFileName(String path)
at Microsoft.Flow.RPA.Desktop.Modules.File.Actions.DeleteFileAction.Execute(ActionContext context)
--- End of inner exception stack trace ---
at Microsoft.Flow.RPA.Desktop.Modules.File.Actions.DeleteFileAction.Execute(ActionContext context)
at Microsoft.Flow.RPA.Desktop.Robin.Engine.Execution.ActionRunner.Run(IActionStatement statement, Dictionary`2 inputArguments, Dictionary`2 outputArguments)

 

i highlighted in red the only thing i can think of that could be wong, maybe there should be a space there? i have no idea...

im pretty new to this and this is quite frustrating, if you can help, please let me know!

  • tsunami3775 Profile Picture
    2 on at
    Re: Illegal characters in path

    My newbie tip or tip for python programmers: Don't use quotation in file path.  Or else it will cause this error.

     

    Don't use this-  "C:\Users\johnc\Desktop\test"

    Use this-   C:\Users\johnc\Desktop\test

     

    It doesn't need pythonic quotations around it or it will produce this error also.  

  • Jlaviolette Profile Picture
    10 on at
    Re: Illegal characters in path

    yes! so i had been putting the file path in as well as the variable and it turns out all i needed was the variable itself.
    its working now.
    now i still need to figure out how to only delete files older than 550 days

  • Verified answer
    eliotcole Profile Picture
    4,266 Super User 2025 Season 1 on at
    Re: Illegal characters in path

    I think that's two paths that have been joined together, @Jlaviolette ... I might not be the person who answers this, but if you include screenshots of your flow, and maybe some example data in a code box, then folks might have a better chance of assisting you, mate. 👍

     

    Just obfuscate anything sensitive, and ensure that it's all in the original question, as that helps folks in the future parse what's going on. 🙂

     

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1