473,398 Members | 2,525 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,398 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 6422
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.