IOException: Sharing violation on path,

Discussion and help for Easy Save 3
Post Reply
eijnew
Posts: 1
Joined: Tue Apr 28, 2020 2:41 am

IOException: Sharing violation on path,

Post by eijnew »

I got an error 'IOException: Sharing violation on path' when trying to delete an encrypted file. The background is when the app found a failed decryption it will delete and recreate a new one.

Here is the sample code, the following code works fine on Mac OS, but reported the previous error on Windows.
Environment: ES3 3.2.1f1, Unity 2018.4.12f1 / Unity 2019.3.2f1 Windows Standalone.

Is it the wrong way to use ES3?

Code: Select all

public void LoadArchive()
    {
        try
        {
            Debug.Log($"Try load archive {ArchiveName} with encrypt key {encryptKey}");
           // presume i used a wrong key to decrypt the archive.
            _archive = new ES3File(ArchiveName, new ES3Settings(ES3.EncryptionType.AES, encryptKey));
        }
        catch (Exception e)
        {
            Debug.Log($"Load failed with key {encryptKey}, delete and re-create");
            // delete invalid archive
           // IOException: Sharing violation on path will be raised when i tried to delete the file.
            ES3.DeleteFile(ArchiveName);

            // create a new one
            CreateArchive();
        }
    }
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: IOException: Sharing violation on path,

Post by Joel »

Hi there,

That's strange, all Streams are put within using blocks, which guarantees that they are disposed if an exception occurs.

I don't appear to be able to replicate this at my end on 2019.3.9f1, so I would first recommend updating Unity just to check it hasn't been previously fixed. If this doesn't resolve the issue, would you be able to private message me a project which replicates this?

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply