Kirk, thank you for the response. I tried your suggestion and unfortunately it did not make a difference. The only thing that seems to kill the .sr.lock files is manually shutting down the ArcMap application, which gets rid of all of the COM references. However, this is not a solution, since I have so many directories worth of shapefiles to run through. The following is a little snippet from my code to show the issue.
pGxObjects.Reset();
while ((pGxDataset = (IGxDataset)pGxObjects.Next()) != null)
{
IFeatureLayer pFeatLayer = new FeatureLayer();
pFeatLayer.FeatureClass = (IFeatureClass)pGxDataset.Dataset;
pFeatLayer.Name = pFeatLayer.FeatureClass.AliasName;
pMxDoc.FocusMap.AddLayer(pFeatLayer);
// Do something with the layer
pMxDoc.FocusMap.DeleteLayer(pFeatLayer);
Marshal.FinalReleaseComObject(pFeatLayer);
Marshal.FinalReleaseComObject(pGxDataset);
}
Marshal.FinalReleaseComObject(pGxObjects);
GC.Collect();
GC.WaitForPendingFinalizers();