473,320 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Why doesn't SHGetSpecialFolderLocation work for "Recycle Bin"?

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();
}
}
Nov 15 '05 #1
1 6413
Frank,
0x000a (which stands for "Recycle Bin") is not even in the list !!
Does that mean SHGetSpecialFolderLocation won't work for "Recycle
Bin"?
No, it just means whoever wrote that code didn't bother to include
that value in the enum. :-)

SHGetSpecialFolderLocation works, but SHGetPathFromIDList doesn't.

Is that because it is a virtual folder?
Yes.

Then how can I get the location of "Recycle Bin"?


I don't think there's any API for that. Keep in mind that the Recycle
bin doesn't have a single backing file system directory, but actually
one per hard drive partition. The virtual folder is a combination of
all of them.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Clint Stowers | last post by:
Access 2k Exporting a Query to as an excel file. No problem. However, I keep getting the warning that the file already exists, Overwrite Yes/No. Yes, I want to overwrite the file. ...
2
by: Derrick | last post by:
and I can't delete them. If I close the project, go delete the folders manually, the items reappear in my project. Any ideas what this is from? I do not see project settings on the "auto add...
6
by: Kevin Mitchell | last post by:
I have an NT shared hosting account, but the provider names the script/write folder cgi-bin. I want to place DLLs in the cgi-bin directory and get them to work in my Web applications. What do I...
5
by: Jim Bancroft | last post by:
New to ASP.Net over here, so apologies if this is a basic question-- I'm using VB .Net to build a managed dll, which I then use in some aspx files. Works fine, except every time I recompile I...
4
by: Brian Pearson | last post by:
Hi, For a web application, is it possible to use something other than the \bin directory for local assemblies? I do not wish to use the GAC. My end goal is to have multiple websites use the...
1
by: Sam Learner | last post by:
Hello, you guys have been very helpfull in responding to questions from the newgroup community and thank everyone for your contributions. I have a Question, I am developping a software to do clean...
2
by: Diffident | last post by:
Hello All, I just finished reading an interesting article by Scott about App Domains: http://odetocode.com/Articles/305.aspx Scott, I have a question about the section "Shadow Copies and...
1
by: Boris | last post by:
We have some .NET 1.1 DLLs which we want to use in a ASP.NET 1.1 web page (actually one is a real .NET DLL in Managed C++ while the others are native Windows DLLs). First we copied all of the DLLs...
2
by: CGatto | last post by:
Hi, We have just started getting the following error during compiles of our forms-based application. We are developing in VS2008, VB.Net, with Team Foundation Server-based source control. ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.