Mark - I think Explorer is slightly different* than what we can do in .NET with purely managed code, but what you have described is corroborated by what I noticed a few days ago (posted here): the deleted files cannot be seen as a standard user, but on logging on as a user with full administration rights you will see the files in the Recycle Bin (those files that have been deleted previously from C:\ root, as a standard user). Which user's Recycle Bins are visible to Admin?
I believe that Vista and later will have this behaviour. * maybe not - Windows Shell is supposed to run as standard user, too. And I also believe that you should be able to get the same result by using either the .NET code I posted, or by using Windows Explorer. The only remedy I can see (to my problem, which is to be able to delete and to perhaps recover, files that reside in the root directory) would be to elevate permissions temporarily for the delete operation; or perhaps for my purposes, just to remove the files to the user's VirtualStore folder, from where it could be reclaimed if necessary. In this blog post <http://blogs.windows.com/windows/archive/b/developers/archive/2009/08/04/us er-account-control-data-redirection.aspx> (no diagrams, but see a link within the blog to a longer MSDN article) there are "Steps to Determine the Most Appropriate Solution". At test #2, I did not see the test file from C:\ root appearing in VirtualStore, but actually in the Recycle Bin - so I judged that article interesting but not applicable - and moved on to investigating whether it would be worth the trouble to elevate permissions (itself an interesting exercise). Elevating permission or impersonating admin user is probably not necessary for my purpose, though. However, I'm puzzled by some common commercial software that will allow writing to user's desktop and any sub-folders (as expected), but will not allow the same user to write to (save files to) sub-folders under C:\ root though those sub-folders can be written to by other programs (eg, anything I write myself, or Explorer etc). _____ Ian Thomas Victoria Park, Western Australia From: [email protected] [mailto:[email protected]] On Behalf Of Mark Hurd Sent: Monday, October 21, 2013 8:33 PM To: ozDotNet Subject: Re: Problem with FileSystem.DeleteFile method in root directory I spent five minutes confirming what happens in Vista if a normal user attempts to delete a file in C:\ that they've been given permission to write to. (I didn't want to adjust C:\'s rights to actually allow them to add and delete files themselves.) It does require elevation (of course) and I then couldn't see the file in the Recycle Bin. (I attempted to open Explorer as Administrator to confirm if I could see it then, but I don't think I really succeeded.) However it was returned when I used Explorer's Undo feature, so it was stored somewhere :-) -- Regards, Mark Hurd, B.Sc.(Ma.)(Hons.)
