My file is marked for deletion by an SMB client and no solution is wokring

Hassan Mansour 0 Reputation points
2025-03-18T03:33:07.6966667+00:00

I was using an IOS app on my IPad named FE File Explorer Pro to access my file share, when i attempted to test my role privileges and see if i could delete a file, it gave me this error code "[0xc0000056] - a non-close operation has been requested of a file object that has a delete pending". i have tried all options to delete include powershell and azure storage explorer but have had no luck. How do i fix this

Azure Files
Azure Files
An Azure service that offers file shares in the cloud.
1,397 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Rahul Gupta 235 Reputation points Microsoft Employee
    2025-03-18T08:34:27.6466667+00:00

    Hello Hassan,

    The error code [0xc0000056]—"a non-close operation has been requested of a file object that has a delete pending"—typically indicates that the file you are trying to delete is locked or is in a state where the system is preparing to delete it but cannot complete the operation.

    Here’s a step-by-step approach to fix this issue and delete the file:

    1. Ensure No Processes are Using the File

    The file might still be open or in use by another process, preventing it from being deleted. Here are some steps to check and resolve this:

    • Close the file on the device: If the file is open in another app (such as FE File Explorer Pro), make sure it is closed. Even if you're accessing it remotely, ensure it's not open on the server or device where the file is stored.
    • Disconnect and reconnect: If you are accessing the file remotely, disconnect from the file share and reconnect. This can help clear up any locks that might be held on the file.
    1. Use PowerShell to Force Delete the File

    If you still have the file locked after closing all apps, you can use PowerShell to forcefully delete the file. Follow these steps:

    1. Open PowerShell as Administrator.
    2. Run the following command to try and delete the file:
    Remove-Item -Path "C:\path\to\your\file.txt" -Force
    

    Replace C:\path\to\your\file.txt with the full path to the file you are trying to delete.

    If this doesn't work due to the file being locked, you may want to use the Sysinternals tool to unlock it (see next step).

    1. Use Sysinternals Process Explorer to Unlock the File

    You can use Sysinternals Process Explorer to find which process is locking the file and terminate that process.

    Download Process Explorer from Microsoft's Sysinternals page.

    Run Process Explorer as an Administrator.

    Press Ctrl + F to open the "Find" dialog.

    Enter the name of the file you are trying to delete.

    Process Explorer will show you which process is locking the file.

    Right-click on the process and select Kill Process to terminate it.

    After terminating the process, try deleting the file again.

    1. Check for Pending File Operations (Windows File System)

    Sometimes, file system operations can get stuck in a "pending" state. To address this, you can try restarting the machine or file share server where the file resides. This can help clear out any pending file operations.

    • Restart the server or local machine where the file is stored, which can help clear the lock and allow you to delete the file.
    1. Use Azure Storage Explorer (for Cloud-Hosted Files)

    If your file share is hosted on Azure File Storage, you can use Azure Storage Explorer to remove the lock or pending delete operation.

    1. Open Azure Storage Explorer.
    2. Connect to your storage account and navigate to the share where the file is located.
    3. Try to delete the file directly from Storage Explorer.
    4. If the file is locked, ensure that no other operations (like uploading or downloading) are in progress.
    5. Check File Share Permissions

    It's possible that a permissions issue is causing the problem. Ensure that you have the appropriate permissions to delete the file from the file share. Even if you're testing your role privileges, there might be something in your permissions setup that is blocking the delete action.

    • Verify your permissions on the file share by going to the Azure Portal or using PowerShell to check the file share permissions.
    1. Check for Active File Locks via SMB (for SMB Shares)

    If you're working with SMB (Server Message Block) shares, you can check for file locks using PowerShell to see if there are any active connections holding the file.

    Open PowerShell as Administrator.

    Run the following command to list active file locks:

    Get-SmbOpenFile
    
    1. If you find any entries for the file you want to delete, use the following command to close the file handle:
         Close-SmbOpenFile -FileId <FileId>
      
      Replace <FileId> with the actual FileId value from the previous command. After closing the file handle, try deleting the file again.
    2. Contact Azure Support (for Azure Storage)

    If the file resides on Azure Storage (such as an Azure File Share or Azure Blob Storage) and you've tried all the steps above without success, there might be a backend issue with Azure. You may need to contact Azure Support for further troubleshooting.

    • Open a support request via the Azure Portal:
      • Go to Help + Support > New support request.

    Summary of Steps:

    1. Close the file on your device or disconnect from the file share.
    2. Force delete the file using PowerShell with the -Force parameter.
    3. Use Process Explorer to find and kill processes locking the file.
    4. Restart the machine or file share server to clear pending operations.
    5. Use Azure Storage Explorer if it's an Azure-hosted file to delete the file.
    6. Ensure you have the appropriate file share permissions.
    7. Use PowerShell to check and close SMB file locks.
    8. If necessary, contact Azure Support.

    By following these steps, you should be able to resolve the file deletion issue. Let me know if you need further assistance!The error code [0xc0000056]—"a non-close operation has been requested of a file object that has a delete pending"—typically indicates that the file you are trying to delete is locked or is in a state where the system is preparing to delete it but cannot complete the operation.

    Here’s a step-by-step approach to fix this issue and delete the file:

    1. Ensure No Processes are Using the File

    The file might still be open or in use by another process, preventing it from being deleted. Here are some steps to check and resolve this:

    • Close the file on the device: If the file is open in another app (such as FE File Explorer Pro), make sure it is closed. Even if you're accessing it remotely, ensure it's not open on the server or device where the file is stored.
    • Disconnect and reconnect: If you are accessing the file remotely, disconnect from the file share and reconnect. This can help clear up any locks that might be held on the file.
    1. Use PowerShell to Force Delete the File

    If you still have the file locked after closing all apps, you can use PowerShell to forcefully delete the file. Follow these steps:

    Open PowerShell as Administrator.

    Run the following command to try and delete the file:

    Remove-Item -Path "C:\path\to\your\file.txt" -Force
    

    Replace C:\path\to\your\file.txt with the full path to the file you are trying to delete.

    If this doesn't work due to the file being locked, you may want to use the Sysinternals tool to unlock it (see next step).

    1. Use Sysinternals Process Explorer to Unlock the File

    You can use Sysinternals Process Explorer to find which process is locking the file and terminate that process.

    Download Process Explorer from Microsoft's Sysinternals page.

    Run Process Explorer as an Administrator.

    Press Ctrl + F to open the "Find" dialog.

    Enter the name of the file you are trying to delete.

    Process Explorer will show you which process is locking the file.

    Right-click on the process and select Kill Process to terminate it.

    After terminating the process, try deleting the file again.

    1. Check for Pending File Operations (Windows File System)

    Sometimes, file system operations can get stuck in a "pending" state. To address this, you can try restarting the machine or file share server where the file resides. This can help clear out any pending file operations.

    • Restart the server or local machine where the file is stored, which can help clear the lock and allow you to delete the file.
    1. Use Azure Storage Explorer (for Cloud-Hosted Files)

    If your file share is hosted on Azure File Storage, you can use Azure Storage Explorer to remove the lock or pending delete operation.

    1. Open Azure Storage Explorer.
    2. Connect to your storage account and navigate to the share where the file is located.
    3. Try to delete the file directly from Storage Explorer.
    4. If the file is locked, ensure that no other operations (like uploading or downloading) are in progress.
    5. Check File Share Permissions

    It's possible that a permissions issue is causing the problem. Ensure that you have the appropriate permissions to delete the file from the file share. Even if you're testing your role privileges, there might be something in your permissions setup that is blocking the delete action.

    • Verify your permissions on the file share by going to the Azure Portal or using PowerShell to check the file share permissions.
    1. Check for Active File Locks via SMB (for SMB Shares)

    If you're working with SMB (Server Message Block) shares, you can check for file locks using PowerShell to see if there are any active connections holding the file.

    Open PowerShell as Administrator.

    Run the following command to list active file locks:

    Get-SmbOpenFile
    

    If you find any entries for the file you want to delete, use the following command to close the file handle:

    Close-SmbOpenFile -FileId <FileId>
    

    Replace <FileId> with the actual FileId value from the previous command.

    After closing the file handle, try deleting the file again.

    By following these steps, you should be able to resolve the file deletion issue. Let me know if you need further assistance!


  2. Nandamuri Pranay Teja 1,690 Reputation points Microsoft External Staff
    2025-03-19T06:05:31.78+00:00

    Hello Hassan,

    This error message clearly indicates that you have a resource lock is placed on your storage account (constructionshares), which restricts your ability to alter role assignments at the file share level.

    • Go to the Azure portal and navigate to your constructionshares storage account.
    • In the left-hand menu, under "Settings," select "Locks."
    • You'll see a list of locks applied to the storage account.
    • Identify the lock that's preventing your role assignment change.
    • In the "Locks" section of your storage account, select the lock you want to remove.
    • Click "Delete."

    Note- Please be informed that locks can be applied at various scopes: subscription, resource group, or individual resource. In your case, the lock is applied at the storage account level. Resource locks are used to prevent accidental deletion or modification of Azure resources. Thay are a security measure to protect critical resources from unintended changes.

    Hope the above answer helps! Please let us know do you have any further queries.


    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members. 

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.