I've got a piece of code that calls the DeleteFile method in the Microsoft.VisualBasic.FileIO.FileSystem class (in the Microsoft.VisualBasic assembly) in order to send the file to the Recycle Bin instead of permanently deleting it. This code is in a managed Windows Service and runs on a Win Server 2k8 machine (32-bit).
The relevant line:
FileSystem.DeleteFile(file.FullName, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin, UICancelOption.DoNothing);
Of course, I've got "using Microsoft.VisualBasic.FileIO;" at the top of the class and I verified that the method being called is really on the FileSystem class in that namespace. In the above line I refer to a local variable "file" - that's a FileInfo for a local file (say, C:\path\to\file.txt) of which I'm certain that it exists. The application has Full Control over both the file and the directory it's in.
This appears to work just fine as the file disappears from the directory it was in. However, the file doesn't show up in the Recycle Bin. I tried inspecting the C:\$Recycle.Bin folders manually as I suspected the Windows Service running in session 0 would make it end up in a different Recycle Bin, but all the Recycle Bins appear empty.
Does anybody have a clue as to what causes this behavior?
By the way - the machine is definitely not out of free space on the drive in question (or any other drive for that matter), and the file is very small (a couple of kilobytes, so it doesn't exceed the Recycle Bin threshold).