Hi.
I wrote a program to get the directory of "Recycle Bin" with
SHGetSpecialFolderLocation .
It works for "Recent", "SendTo", etc. but it doesn't work for "Recycle
Bin".
At http://www.dot.net.nz/codesamples.browseforfolder.aspx , and other
places,
the folder Ids are:
///
/// Enum of CSIDLs identifying standard shell folders.
///
public enum FolderID
{
Desktop = 0x0000,
Printers = 0x0004,
MyDocuments = 0x0005,
Favorites = 0x0006,
Recent = 0x0008,
SendTo = 0x0009,
StartMenu = 0x000b,
MyComputer = 0x0011,
NetworkNeighborhood = 0x0012,
Templates = 0x0015,
MyPictures = 0x0027,
NetAndDialUpConnections = 0x0031,
}
0x000a (which stands for "Recycle Bin") is not even in the list !!
Does that mean SHGetSpecialFolderLocation won't work for "Recycle
Bin"?
Is that because it is a virtual folder?
Then how can I get the location of "Recycle Bin"?
Thanks for your help in advance.
Frank
PS: I posted my codes below:
//////////////////
[DllImport ( "Shell32.DLL" )]
static extern int SHGetSpecialFolderLocation(IntPtr hwndOwner,
int nFolder, out IntPtr ppidl);
[DllImport ( "Shell32.DLL" )]
public static extern Int32 SHGetPathFromIDList(
IntPtr pidl, // Address of an item identifier list that
StringBuilder pszPath);
[STAThread]
static void Main(string[] args)
{
IntPtr pidl = IntPtr.Zero;
int CSIDL_BITBUCKET = 10; // Recycle Bin - virtual folder
// int CSIDL_BITBUCKET = 9; // SendTo Works !!
string TempString;
if( 0 == SHGetSpecialFolderLocation( (System.IntPtr)null,
CSIDL_BITBUCKET, out pidl ) )
{
// Then retrieve the path from the IDList.
StringBuilder sb = new StringBuilder ( 1000 );
SHGetPathFromIDList( pidl, sb );
TempString=sb.ToString();
}
}