The first time I ever worked with file system actions in Power Automate, I spent 2 hours trying to get the flow to run correctly. It was infuriating. I struggled that long because the errors shown had nothing to do with the actual problem. Also, Microsoft has some conventions that can lead you down the wrong path. Read this post before using File System actions to avoid major roadblocks.
Let’s start with how to use and configure file system actions. For this example, I will configure a Create file action.
How to Use File System Actions
- Click on the Add action or New Step button in Power Automate. Type in File System to search for File System actions. Then search for or click on Create file.
- If this is your first time using file system actions, the action default to the screenshot show in step 3 whereby you must create a connection. If you have existing connections, click on the three dots and select the appropriate connection.
- Create a new connection. Give the connection a name that will indicate where you are connecting to. You might have more than one connection eventually. If you connect to a network drive, the root folder will start with “\\”, as opposed to connecting to a “C:\” drive as shown. It does not matter if you end the file path with a slash, such as \\companyfile\shared\”. Do not use mapped drive paths, like “D:\”. Additionally, if you work with a shared drive structure, you only need to configure the root drive, which might look like “\\companyfile\shared\” instead of a longer pather with more subfolders. You will still be able to connect to subfolders. Windows authentication is the only option in my drop down. The username must be preceded by a domain name, like “abc\jsebby”. Without the domain, Power Automate will give you a nonsensical error. Each company will have a different gateway set up, so choose according to what is set up for your company. For more information on gateways, check out this link. The linked content uses the term “on-premise” frequently. On-premises means hosted on-site, as opposed to stored in the cloud.
- Then, configure the File System file path. Enter the full file path for where you want to connect in Folder path. For the file name, you may type in the name of the file or use dynamic content. In this case, I am saving an attachment from an email, and I take the file name that came thru with the email. For file content, you will likely need to use dynamic content. In this case, my email trigger provided dynamic content for the file contents that came thru with the email.
Troubleshooting File System Actions
If you run into this error, it appears as if the problem is related to a bad file path. The Error Details window shows a forward slash before the file name. However, this problem is not related to the file path, and that forward slash doesn’t really exixt. The problem is the connection setup. More specifically, the username doesn’t have a domain associated with it (see step 3 above).
We can confirm the error is caused by a bad connection by clicking on the folder icon in the top right-hand corner of the action, to the right of the file path. When you click on the folder and attempt to navigate thru the folder structure, this will produce an error that tells us the connection isn’t connecting.
When creating the connection, you must include the domain name before the user name. This error might also present itself if/when the password was incorrect or had been changed.
Helpful Tips For File System Actions
Tip No 1
You cannot convert file types with the Create file action. If you need to convert the file type, this must be done in some other way, such as with Power Automate Desktop, which I wrote about in this post.
Tip No 2
If you are troubleshooting an error and you happen to click on Show Raw Inputs in the Create File action, it will appear as if there are extra slashes in the file path. This is a Microsoft convention. This is not wrong. Just ignore this. I don’t know why MS does this. If you do, please leave me a comment, and I’ll update the post.
Okay, that wraps up this post on learning to use file system actions in Power Automate. Hopefully, I’ve saved at least a few people the same struggles I experienced when working with file system actions.
Thanks for this. Any idea how to overwrite an existing file time and time again using the create file power automate function?
Are you getting an error saying the file can’t be overwritten?
I have a question. I set this up and everything looks good. I’m trying to move newly created files on a shared drive to a folder in Sharepoint.
When setting it up in Power Automate, I can browse my file strucute on a local shared drive. I can also browse the file structure in Sharepoint. Everything seems to talk to one another with no errors in the flow.
However, in the ‘run history’, no flows are running. I let it sit for 24hrs and there is no history of the flow running. No files were moved either into Sharepoint.
We have an enterprice E3 license, but it sounds like even the free version should still work, so I don’t think it is a licensing issue
What is your trigger?
How does PW determine what path to make available in the “List Files In Folder” selector? I can only see “My Files” paths, but I need to be able to see our company “sites” paths. This is a flow that was “shared with me” and is owned by another user. I can see a Connection under his name, and one under mine, but not matter which I select, I get the same choices in the path selection UI in the step.
You may need to add another file system connection or modify what is already setup. To create new, go to the Data menu on the left-hand side of the screen. Go to the Connections submenu. Create a new File System connection. You’ll need to specify the root folder when you create the connection, which is how you make company file paths visible. The choices you see in the folder path step are determined by what is entered for the root folder. The connection must be a networked file path and not a mapped drive. If you have already done this, then I would double check what is setup. It’s possible the existing root folder is pointing to the wrong place. It’s also possible there is some type of security protocol prohibiting it.
Thanks Julie for this great content. It helped me rethink how I was getting errors in my flow and I was able get my flows working as planned.
That’s awesome! I’m glad it was helpful.
Hello Julie, thanks for your post! In my case I am getting Error ‘400’ (shown above in your print screen), but I have checked many times the connection, and I am pretty sure the connection is ok. It also says “connected” on its status. Any idea of what could be happening?
It has to be a connection problem.
The double slashes are not a “Microsoft” convention. “\” is an escape character in JavaScript, C# and json (which is used here), so if you want to put a “\” in a string you have to put two so that it identifies the slash correctly. See https://en.wikipedia.org/wiki/Escape_character
Thank you!
The additional \ are a JSON thing, \ is a special character and needs to be escaped for it to appear in the string correctly.
Bit more info on JSON escape characters can be found here: https://stackoverflow.com/questions/19176024/how-to-escape-special-characters-in-building-a-json-string
Finally an explanation!
Hi Julie. I’m assuming that you MUST use a gateway, even if your file server is a VM in the cloud.
Anyway around this?
Probably not but thought I’d ask.
Thanks
You are correct. We do use a gateway.