For loop File.Delete doesn't work

When I run my script inside Unity, this function works just fine but when I Build and Run it, this function doesn’t delete all the files.

Anyone has an idea?

public void NewGame()
{
    string pathFile = Application.persistentDataPath;
    if (Directory.Exists(pathFile))
    {
        var files = Directory.GetFiles(pathFile);
        for (int i = 0; i < files.Length; i++)
        {
            File.Delete(files[i]);
        }
    }
}

Most likely there where some files in the directory that couldn’t be deleted on Runtime, so my work around is the following.

public void NewGame()
{
  string fileType = "*.json";
  string pathFile = Application.persistentDataPath;
  if (Directory.Exists(pathFile))
  {
      var files = Directory.GetFiles(pathFile, fileType);
      for (int i = 0; i < files.Length; i++)
      {
          File.Delete(files[i]);
      }
  }
}