Please follow below tips to troubleshoot the issue.
1.Make sure the file is not checked out to another user. And the file is not opened in your device or other devices.
2.Go to Library settings -> Apply label to items in this list or library -> On the Apply Label, you can select "None" from the drop-down box and check the "Apply label to existing items in the library" check box -> Save.
Then try to delete the file again.
3.Try to delete file by using following PowerShell.
#Config Variables
$SiteURL = "https://Crescent.sharepoint.com/sites/emilytest"
$FileRelativeURL ="/sites/emilytest/Shared Documents/test.xlsx"
#Get Credentials to connect
$Cred = Get-Credential
Try {
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials $Cred
#Try to Get File
$File = Get-PnPFile -Url $FileRelativeURL -ErrorAction SilentlyContinue
If($File)
{
#Delete the File
Remove-PnPFile -ServerRelativeUrl $FileRelativeURL -Force
Write-Host -f Green "File $FileRelativeURL deleted successfully!"
}
Else
{
Write-Host -f Yellow "Could not Find File at $FileRelativeURL"
}
}
catch {
write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.