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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / OneDrive tool: Copy fi...
Power Automate
Suggested Answer

OneDrive tool: Copy file using path OneDrive --> access is locked

(0) ShareShare
ReportReport
Posted on by 39
Hello,
 
I am facing a issue while trying to copy xlsx files on my OneDrive directory where there are 3 files : A, B and C. 
Here is the very simple set up of the flow :
action 1 - Copy path B to C => OK
action 2 - Copy path A to B => Action 'Copy_source_to_working_path' failed: The resource you are attempting to access is locked
 
I tried to put a Delay between action 1 and 2, of 40 seconds, but I have the same error on action 2.
 
 
If I try the following :
action 1 - Copy path A to C => OK
action 2 - Copy path B to C => OK
 
Which leads me to the conclusion the problem is on file B.
 
I have tried to disconnect the OneDrive widget on my MacBook, closing OneDrive window, to avoid any concurrent access to B, making sure B is not "in use".
 
I still have the problem wherever I run Copy path A to B => Action 'Copy_source_to_working_path' failed: The resource you are attempting to access is locked
 
Did you already face this ? Do I miss something ?
Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,335 Most Valuable Professional on at
     
     
    Just to double check, are you using the overwrite option?
     
    Just tried to reproduce your issue. And the below setup seems to work ok. I am unable to reproduce.
     



     
    Happy to help out 😁

    I share more #PowerAutomate and #SharePointOnline content on my Blog, LinkedIn, Bluesky profile or Youtube Channel
  • Gilles495 Profile Picture
    39 on at
     
    Thx for your reply.
     
    I forgot to menton, all the tests done with this overwrite setting to Yes.
     
  • Expiscornovus Profile Picture
    33,335 Most Valuable Professional on at
     
    Can you share what you are using in that concat expression?
     
     
    Happy to help out 😁

    I share more #PowerAutomate and #SharePointOnline content on my Blog, LinkedIn, Bluesky profile or Youtube Channel
  • Gilles495 Profile Picture
    39 on at
    sure:
    concat('/GiG_Consulting/INV-', formatDateTime(utcNow(), 'yyyyMM'), '-',triggerBody()?['text'],'.xlsx')
     
     
    Thx !
  • Gilles495 Profile Picture
    39 on at
    I am wondering whether this has something to do with File System management working in the background.
    I notice if I call the action "Update a Row" in a XLSD file, on Onedrive browser, I see the field "modified" at least 40 secs after the action is passed.
     
    Since I am in a Developper Environment, and given the observation of @Romain The Low-Code Bearded Bear who contemplated a difference of performances between Dev vs. Production Env, could it be that XLSX file I'm trying to write into, is locked by the File System Manager because of the the action "Update a Row" which locked the file from any attempt of Update (considering Copy is an update) ?
     
    I tried to set a Delay of one min between the actions "Update the row" and "Copy" into the same file, unfortunately, the file is still Locked.
     
    Could it be the reason ?
    If so, what would you advise, setting up a longer Delay (one min is a lot but maybe not sufficient).
     
  • Suggested answer
    Romain The Low-Code Bearded Bear Profile Picture
    2,296 Super User 2025 Season 2 on at
    @Gilles495 since other member manage to make it work, it's strange.
     
    What i can recommand, is something similar to the same problem in "old" powershell environnement ^^ i meen "the refresh contexte".
     
    So my idea is : probably in dev environnement the action are made withtout delay BUT the contexte inside of the flow is not update.
     
    Could you try to cut into : two flow to check is it's just not a context issue ?
    Execute first move, then executy second moove but from another flow ?
     
    did you try with other file or folder ?
    Did you try when it's inside a folder ? at the root ?
     
    All of my idea could seem strange but "in old day" :D there use to be problem in .net en powershell with this situation :D so why not with power automate ?
  • Expiscornovus Profile Picture
    33,335 Most Valuable Professional on at
     
    Just to double check. I thought the full flow setup was only two copy actions?
     
    But do you have more actions in your setup? Like an update row action of the Excel connector? If so, can you share the full setup?
     
    And yes, it is very likely you would still have a lock on the file if you made an modification to that file earlier in the flow. In that case you might use a locked file check pattern like for example the one of Tomasz, https://poszytek.eu/en/microsoft-en/office-365-en/powerautomate-en/locked-file-checking-pattern-in-power-automate/
     
     
    Happy to help out 😁

    I share more #PowerAutomate and #SharePointOnline content on my Blog, LinkedIn, Bluesky profile or Youtube Channel
  • Suggested answer
    Gilles495 Profile Picture
    39 on at
    bonjour @Romain The Low-Code Bearded Bear,

    Merci pour ce retour éclairé.
     
    Isoler les action copy dans un autre fliux n'a pas résolu le problème.
    Cependant, en copiant les deux fichiers dans un autre répertoire "autre", oui.
     
    Vu que j'ai fait pas mal de manip sur les XL, et en particulier sur fichier destination de la copie, je crois bien que j'ai cassé des références internes qui ont jetées la confusion, ie. je pense que dans ma logique je travaillais sur le bon fichier destination là où Power automate gardait une ancienne référence d'un fichier fantôme.
    C'est mon analyse, elle vaut ce qu'elle vaut .... 8-)
     
    Mon objectif initial :
    Avoir un fichier XL draft sur lequel j'opérais des Update Row, sur des références de tables du fichier, puis en fin de flux je l'écrasais avec un fichier XL modèle afin de repartir sur le fichier de départ pour les prochains cycles.
     
    L'observation :
    Même si Copilot m'affirme qu'à partir du moment où les deux XL sont strictement identiques (nom des tables, position, etc.) je ne casse pas les références aux tables internes du fichier draft exploitées dans mon flux, l'expérience m'a enseigné le contraire. Les références de tables sont modifiées par la copie.
     
    La conclusion
    L'idée de copier un fichier modèle vers un draft ne fonctionne pas comme espéré avec Power Automate
     
    La solution :
    Reste plus qu'a faire les action Update Row de restauration en fin de flux. Ce n'est pas très élégant mais je contourne la difficulté.
     
    Observation étrange :
    Je constate que faire un PDF d'un fichier qui a subit des Update Row dans un même flux ne fonctionne pas de façon déterministe. Autant le fichier Draft XL de travail est bien modifié, autant le fichier PDF reflète ces modifications parfois oui, parfois non.
     
    C'est étrange ce côté non déterministe quand justement on utilise Power Automate pour cette caractéristique qui le rend si unique ! :-)
  • Gilles495 Profile Picture
    39 on at
    Sorry, I realize I wrote in french, which is not good for the community, my bad !!
    Here is the translation.
     
     
    Thank you for this enlightened feedback.
     
    Isolating the copy actions in another flow did not solve the problem.
    However, by copying the two files to another 'other' directory, yes.
     
    Since I did quite a few things on the XL, and in particular on the copy destination file, I believe that I broke internal references which threw off the confusion, ie. I think that in my logic I was working on the correct destination file where Power Automate kept an old reference of a ghost file.
    This is my analysis, it’s worth what it’s worth .... 8-)
     
    My initial objective:
    Having an XL draft file on which I was operating Update Rows, on table references of the file, then at the end of the flow I overwritten it with a template XL file in order to start again on the starting file for the next cycles.
     
    The observation:
    Even if Copilot tells me that from the moment when the two XL are strictly identical (table names, position, etc.) I do not break the references to the internal tables of the draft file used in my flow, experience has taught me the opposite. Table references are modified by the copy.
     
    The conclusion
    The idea of copying a template file to a draft does not work as expected with Power Automate
     
    The solution:
    All that remains is to do the Update Row restore actions at the end of the flow. It’s not very elegant but I’m bypassing the difficulty.
     
    Strange observation:
    I notice that making a PDF of a file that has undergone Update Rows in the same stream does not work deterministically. As much as the working Draft XL file is well modified, the PDF file reflects these modifications sometimes yes, sometimes no.
     
    It’s strange, this non-deterministic side when we precisely use Power Automate for this characteristic that makes it so unique!: -)
  • Gilles495 Profile Picture
    39 on at
     
    Thanks for the sharing, very insightful.
     
    As I said in another answer, I think I messed around with with the files and as a matter of fact I lost Power Automate in that mess.
     
    My last pain point is I notice when I update a row in an XL file, and then run a file conversion to PDF (input in the literal file path of the source file), the result sometimes reflect the XL file with the updated rows, sometimes no, even though I can see the effective update in the XL file if I open it.
    I added in between a 45 Sec Delay "in case of", but that doesn't matter.
     
    If you have any idea, you're welcome :-)
     
     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 255 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 169 Super User 2025 Season 2

#3
harshdeol Profile Picture

harshdeol 167 Moderator

Last 30 days Overall leaderboard