Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Can't .DeleteRealm() Even After .Dispose() #1970
Trying to replace a .realm file used by a configuration offline.
After I .Dispose() the instance, I expect .DeleteRealm() to remove all files associated with it.
Error thrown. File in use by another process.
Steps to Reproduce
Create a Realm instance, attach a .RealmChanged handler, and get a reference to the .All.
Trying to copy .realm file with same format from a USB Drive
Error thrown: The process cannot access the file '...\test.realm' because it is being used by another process.
I've already seen this thread, which is the closest I've found to my issue and a possible solution, although it was for IOS so I'm not sure how much is applicable to my situation.
Version of Realm and Tooling
When you open a synchronized realm the framework spawns a worker thread which runs the sync session. By default after you close the last instance of a synchronized realm file its sync session lingers a bit more in the worker thread to make sure that changes are propagated.
It seems like you're opening a realm and then shortly thereafter disposing it and trying to delete it. What I think is happening is that the sync session is still performing synchronization in the background, because when you open a synchronized realm with
My suggestion is to try using
Alternatively, you can call
Out of curiosity, under what circumstances do you need to delete a synchronized realm file? If it's a file you'll be opening again that'll just mean it'll need to be downloaded from the server all over again as opposed to just resuming from where it left off.
@fealebenpae You almost solved my issue! Not sure why, but I can successfully overwrite the file but only once...
Now I just need to find why I can only do overwrite once...