The process cannot access the file ‘C:\inetpub\wwwroot\*’ because it is being used by another process.


We can check if the file is used by another process

try
{
    using (FileStream fs = File.Open(FilePath, FileMode.Open, FileAccess.ReadWrite, FileShare.None))
    {
        fs.Close();
    }
    // The file is not locked
}
catch (Exception ex)
{
    ErrorMsg = "File is locked by another process.!");   
}