I have a commercial ASP.NET application running on hundreds of servers. One customer is experiencing the error below when the app tries to move a directory on a file share accessed via UNC syntax.
System.IO.IOException: The directory is not empty.
Stack trace:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.Directory.InternalMove(String sourceDirName, String destDirName, Boolean checkHost)
at GalleryServer.Business.AlbumSaveBehavior.PersistToFileSystemStore(IAlbum album)
at GalleryServer.Business.AlbumSaveBehavior.Save()
at GalleryServer.Business.GalleryObject.Save()
at GalleryServer.Business.Album.MoveTo(IAlbum destinationAlbum)
at GalleryServer.Web.Controller.AlbumController.TransferToAlbum(Int32 destinationAlbumId, GalleryItem[] itemsToTransfer, GalleryAssetTransferType transferType, GalleryItem[] createdGalleryItems)
at GalleryServer.Web.Api.AlbumsController.TransferTo(Int32 destinationAlbumId, GalleryItem[] itemsToTransfer, GalleryAssetTransferType transferType)
The code looks like this (simplified):
var sourceDir = @"\\server\storage\folder1";
var destDir = @"\\server\storage\folder2";
System.IO.Directory.Move(sourceDir, destDir);
I should note that the code succeeds when the directory is empty. It should work when it contains files, and indeed it does for other customers.
The ASP.NET app is running in IIS with an AD account for the application pool identity. I've confirmed it has 'modify' permission to the file share directories.
What kind of server configuration or permission condition could trigger this error? I've run a number of tests on my own and can't repro it.