Delete a Realm - .NET SDK
In some circumstances, such as a client reset scenario, you might need to delete a realm file and its auxiliary files. If you are developing or debugging the app, you might manually delete the realm file, but doing so when the app is running and any realm instances are still open can cause data corruption.
To delete a realm file while the app is running, you can use the DeleteRealm(configuration) method to safely do so. The following code demonstrates this:
var config = new RealmConfiguration("FileWeThrowAway.realm"); Realm.DeleteRealm(config); var freshRealm = Realm.GetInstance(config);
Warning
Use Caution When Deleting Realm Files
If you delete a realm file or any of its auxiliary files while one or more instances of the realm are open, you might corrupt the realm or disrupt sync.
You may delete these files when all instances of a realm are closed. Before you delete a realm file, however, be sure that you back up any important objects as you will lose all unsynced data in the realm.