The process cannot access the file because it is being used by another process 2 I have log shipping enabled on my database. I created a file, with let's say logical name 'AB' of 50 MB at location E:\Databases\AB.ndf. However, I later dropped this file and created another file with logical name 'AB_File' of 10 MB at same location E:\Databases\AB.ndf. Now the server where the backup was moved to is failing with error:

Error: 

1) Could not apply log backup file 'some location of a .trn file' to secondary database

2)The operating system returned the error '32(The process cannot access the file because it is being used by another process.)' while attempting 'RestoreContainer::ValidateTargetForCreation' on 'E:\Databases\AB.ndf'.

3) File 'AB_File' cannot be restored to 'E:\Databases\AB.ndf'. Use WITH MOVE to identify a valid location for the file.


I have tried running the following script:

RESTORE LOG [db_name] FROM
DISK =  'E:\Log_Shipping\\db_name_20160817070500.trn'
WITH MOVE 'AB_FILE'
TO 'E:\Databases\AB.ndf',
standby = N'E:\Databases\\db_name_20160818.tuf'


I don't seem to be able to fix this. Please help!

The file location on the backup server is the same as that on primary server. Also, the file-group was dropped and the file names are correct.
As you said the error


  The operating system returned the error '32(The process cannot access
  the file because it is being used by another process.)' while
  attempting 'RestoreContainer::ValidateTargetForCreation'


The reason for this is that the name of the database files of the databases you are trying to restore already exists.

This could be for two reasons, either you have used the same create scripts for the same database on all instances or you have already done a restore of the database you are trying to restore now to that instance.

To solve this issue do the following:


  
  In the restore page in SSMS, press the "options" tab.
  In the "Restore as" column change the name of the datafile(s) and log file to something unique.
  


Then hit the restore button and that should be it.

for your ref Here