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 / Help with Write to File
Power Automate
Answered

Help with Write to File

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I'm trying to use "Get file path part" and extract just the file name without extension.

 

I want to send this list of file names to a .txt somewhere on my agency's filestore, but I keep getting the same error when trying to target both the shared drive and local file structure:

 

Microsoft.Flow.RPA.Desktop.Robin.SDK.ActionException: Invalid directory specified ('Access to the path 'C:\Users\jakso\Desktop\test location\CSV Home' is denied.') ---> System.UnauthorizedAccessException: Access to the path 'C:\Users\jakso\Desktop\test location\CSV Home' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)
at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding)
at Microsoft.Flow.RPA.Desktop.Modules.File.Actions.WriteTextToFileAction.Execute(ActionContext context)
--- End of inner exception stack trace ---
at Microsoft.Flow.RPA.Desktop.Modules.File.Actions.WriteTextToFileAction.Execute(ActionContext context)
at Microsoft.Flow.RPA.Desktop.Robin.Engine.ActionRunner.RunAction(String action, Dictionary`2 inputArguments, Dictionary`2 outputArguments, IActionStatement statement)

 

Can someone explain what I'm doing wrong?

 

Thank you!

I have the same question (0)
  • VJR Profile Picture
    7,635 on at

    Hi @Anonymous 

     

    I was able to write just the file name without extension to a Text file without any issues.

     

    The error message in your post is showing as below

     Invalid directory specified ('Access to the path 'C:\Users\jakso\Desktop\test location\CSV Home' is denied.)

     

    1. When do you get this error? On which action?

    2. Can you check if you have access to C:\Users\jakso\Desktop\test location\CSV Home

    3. Some do not have access to create anything on Desktop through automation processes. Check if you are able to create the text file on some other path that does not include the default windows folders (like Desktop, My documents, Users, etc)

    3. Can you also manually try to create a Text file on this location and see whether you are able to create it or not

    4. Also share some screenshots of the PAD flow and also the contents of the action where you are getting the error.

     

     

     

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    If you still can “get file path part” to work, you can use “get files” and for each file use the “%CurrentItem.NameWithoutExtension% property to get it where you need it to go. 

    Best of Luck!

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    My flow is made of 2 actions.

    1. get the file path part so that there is data to write to the text file

    2. write the data to a text file at the specified location.

     

    I get the error mentioned in the OP when my flow tries to execute step 2. "Write text to file". I have access to every (non system locked like sys32) directory in the computer. I even have access to every directory I attempted in the shared drive. I haven't tried non default folders like you mentioned.

     

    I'll take a screen shot of the error window if I still can't get it to write to a file in a non default directory.

  • Verified answer
    Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I made a text file in a folder tree under My Documents (the Windows default one) and inside that created text file in my newly created folder path I'm no longer getting OP's error.

     

    I think what was causing the error originally is that I had targeted a folder path and not a file path. If you look at the folder path you'll note that it doesn't end in a file, it ends in a folder.

     

    Changing the directory to look at a text file in my flow caused the flow to send text to that file, but not if the directory ends in a folder.

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
David_MA Profile Picture

David_MA 266 Super User 2026 Season 2

#2
trice602 Profile Picture

trice602 160 Super User 2026 Season 2

#3
11manish Profile Picture

11manish 134 Super User 2026 Season 2

Last 30 days Overall leaderboard