Path to Recycle Bin can be obtained by PInvoking SHGetSpecialFolderLocation:
static void Main(string[] args)
{
const int CSIDL_BITBUCKET = 0x000a;
StringBuilder buffer = new StringBuilder(256);
int ret = SHGetSpecialFolderPath(IntPtr.Zero, buffer, CSIDL_BITBUCKET,
false);
IntPtr pidl;
SHGetSpecialFolderLocation(IntPtr.Zero, CSIDL_BITBUCKET, out pidl);
SHGetPathFromIDList(pidl, buffer);
Console.WriteLine(buffer.ToString());
}
[DllImport("coredll")]
extern static int SHGetSpecialFolderPath(IntPtr hWnd, StringBuilder buffer,
int Folder, bool Create);
[DllImport("ceshell")]
extern static int SHGetSpecialFolderLocation(IntPtr hWnd, int Folder, out
IntPtr pidl);
[DllImport("ceshell")]
extern static int SHGetPathFromIDList( IntPtr pidl, StringBuilder pszPath );
A bit of problem with this code is that it does not free memory allocated to
pidl. If you are going to call this once or twice over your app lifetime,
it's not a big deal. If however you are going to keep calling this, you will
need to do this properly in unmanaged code:
IMalloc pMalloc;
SHGetMalloc(&pMalloc);
pMalloc->Free(pidl);
pMalloc->Release();
--
Alex Feinman
---
Visit
http://www.opennetcf.org
Gianco said:
Hello
Is there a function to delete all files from the recycle bin or, which
is the path to access to the recycle bin?
Thanks in advance
Gianco