Joseph
Joseph

Reputation: 55

Sharing violation when attempting to delete a file in c# script

I have a very simple piece of code, It should work by detecting if a file exists and if so then delete the file. However when I run the code in the unity editor I get the following error: IOException: Sharing violation on path Assets\Plugins\Rooms Table.db

here is my code:

    if(System.IO.File.Exists(@"Assets\Plugins\Rooms Table.db"))
    {
    System.IO.File.Delete(@"Assets\Plugins\Rooms Table.db");
    }

Upvotes: 1

Views: 2357

Answers (1)

Joseph
Joseph

Reputation: 55

I discovered the reason for my problem was that the folder containing my file was open in my code editor.

Upvotes: 1

Related Questions