The .NET Framework doesn't have built-in support for this, but you can call
the Shell Win32 API function SHFileOperation along with the flag
FOF_ALLOWUNDO.
"When used to delete a file, SHFileOperation permanently deletes the file
unless you set the FOF_ALLOWUNDO flag in the fFlags member of the
SHFILEOPSTRUCT structure pointed to by lpFileOp. Setting that flag sends the
file to the Recycle Bin. If you want to delete a file and guarantee that it
is not placed in the Recycle Bin, use DeleteFile."
The .NET Framework doesn't have built-in support for this, but you can call
the Shell Win32 API function SHFileOperation along with the flag
FOF_ALLOWUNDO.
Terrific, Jani. I think that fills in the blanks. I suspected that I'd
have to go with Pinvoke. My first run at SHFileOp didn't work, but I
think you've clarified the missing flag.
I'm surprised that the .NET 2005 library still has holes in some
pretty fundamental operations. This seems like it would have been easy
for MS to wrap in the C# library.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.