Error: Non-static method Drupal\Core\File\FileSystemInterface::delete() cannot be called statically

In drupal 9 you can often get errors like this. You should work the OO way of using classes, or use services. Here you can use the service:

\Drupal::service('file_system')->delete($fileLocation);

 

 

Saved you some valuable time?

Buy me a drink 🍺 to keep me motivated to create free content like this!