473,396 Members | 1,871 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,396 software developers and data experts.

empty recycle bin with c#

Hi,

I wrote some code using the shell32.dll to query the size of the
recycle bin. The function does not produce an error but the results
are not correct:

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
public struct SHQUERYRBINFO
{
public Int32 cbSize;
public UInt64 i64Size;
public UInt64 i64NumItems;
}

[DllImport("shell32.dll" , CharSet = CharSet.Unicode)]
public static extern int SHQueryRecycleBin(
[MarshalAs(UnmanagedType.LPTStr)]
String pszRootPath,
ref SHQUERYRBINFO pSHQueryRBInfo
);

SHQUERYRBINFO bb_query = new SHQUERYRBINFO();
bb_query.cbSize = Marshal.SizeOf(bb_query.GetType());
iRetVal = (int)SHQueryRecycleBin(BitBucket_Path, ref bb_query);
iRetVal is 0, but:

* if there are elements in the recycle bin the size is always
4294967296 and the number of elements is 0

* if the recycle bin is empty the size is 0 and the number of elements
is 0 (this is correct)

Any hints what's wrong? Are there other shell32 functions to query
single objects in the bin?

Thanks for your help,

Thomas
Nov 15 '05 #1
1 2787
Thomas,

Add Pack=1 to the StructLayout attribute on SHQUERYRBINFO.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
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

1
by: Kerem Gümrükcü | last post by:
Hi, how can i get the pyhsical path to a recycle bin object. i am working with the FileSystemWatcher Object and i dont want to handle events inside the recycle bin, because the FSW Object...
1
by: Frank Meng | last post by:
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...
5
by: Gene Vital | last post by:
Can someone point me in the right direction on how to send files to the Recyle Bin using C#.
2
by: John | last post by:
Is the only criteria for worker process recycle 60% physical memory usage?? (I'm on W2K, default setup - I know you can change it in machine.config). Because if so, when using SQL Server on the...
5
by: johnb41 | last post by:
I searched and found a way (via API) t0 add a deleted file to the recycle bin. (Thanks Ken Tucker! :)) But I was wondering if VB.NET 2005 (framework 2.0) has a non-api solution. (Note: i...
2
by: vighnesh | last post by:
Hi All Can Anybody Please help me in how to Empty a Recycle bin using VB.NET code ? Regards Vighneswar
3
by: amocksun | last post by:
Hi, this is my first post on here, and I am am here because I seriously need some help with my Vista. My problem is I accidentally deleted nearly all my save files for my favorite game, about 30...
5
by: fniles | last post by:
I am using VB.NET 2005. When I try to delete a folder that has files underneath it, it gave me "the directory is not empty" error. f = New IO.DirectoryInfo("C:\myfolder") If f.Exists Then...
2
by: =?Utf-8?B?VVNBT3o=?= | last post by:
I am using Windows Vista Ultimate (x86). I accidently deleted my Desktop Recycle Bin. I restored it (Control Panel/Personalise/Change Desktop Icons). I clicked on the Recycle Bin (Full) icon...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.