Sharing violation basically means you have multiple applications on your computer holding a file handle to your file at once, and potentially trying to read/write from it simultaneously. Restarting your computer is a good nuclear option to clear out any such file handles, but really you can just make sure you only have one application with the file open at once.
It could also potentially be a bug in Unity or your IDE where they are not properly cleaning up their file handles under certain circumstances. No software is perfect ![]()