Share via

OneDrive locking files?

Al Boggess 1 Reputation point
2021-12-01T15:57:22.227+00:00

I'm a developer for a C++ MFC desktop application. The application does many file manipulations (read, write, move, copy, delete, etc). When one of these operations fails, we usually log it and retry. After a number of retries, we try to figure out what is locking the file, print that to the logs, and give up. We've noticed that OneDrive is often the application locking the files (I can post portions of the source code if needed).

So my questions are:

1) Is it actually OneDrive locking the file perhaps during sync operations? Or is there something else going on and it just looks like it's one drive?

2) If OneDrive is actually the one locking the files, is there a way we can "play nice" with OneDrive so that we don't keep stepping on it? E.g. debounce our save processes or something?

Microsoft 365 and Office | OneDrive | For business | Windows
0 comments No comments

1 answer

Sort by: Most helpful
  1. Emily Hua-MSFT 27,911 Reputation points
    2021-12-02T07:15:57.777+00:00

    Hi @Al Boggess

    Welcome to Q&A forum ~

    At present, I have not found relevant documents to directly answer your question 1: Will OneDrive lock the file perhaps during sync operations?
    Thanks for your understanding.

    As far as I know, if an app is using a file that you have stored on OneDrive, it cannot be synced while the file is open, there would be a message like following image.
    154392-capture3.jpg
    Once you have saved your work, and closed this app, OneDrive will sync the file.
    So in my opinion, during the synchronization of the file with OneDrive, it must be the case that other software is not doing something on the file.

    For the second question, it is recommended that your application process the files before OneDrive synchronizes the files, or after the OneDrive sync files are completed.

    Hope the information is helpful to you.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.