what is the path to Recycle bin?
-
Friday, March 09, 2007 9:19 PMI would like to know the path for accessing Windows Recycle bin in XP and also in Vista. thanks.
All Replies
-
Friday, March 09, 2007 11:17 PMNot sure if there is any VB wrapper for this but you in win32 you would call the SHGetSpecialFolderPath function and give the CSIDL_BITBUCKET as CSIDL parameter.
-
Saturday, March 10, 2007 2:56 AM
You need SHGetSpecialFolderLocation() to access path of Recycle Bin Folder.
http://www.codeproject.com/shell/recyclebin.asp <==== This is similar what you are looking for- Proposed As Answer by AKGMA Friday, October 09, 2009 7:10 AM
-
Saturday, March 10, 2007 3:13 AMto overwrite the files that are in RECYCLE BIN.
Create Dummy files at same path location and move them to recycle bin. Use function SHFileOperation() to send file to recycle bin. -
Monday, March 12, 2007 8:48 PM
It has 5 paths. Use any one of them:
C:\RECYCLER\S-1-5-21-1089551744-1120685985-1162132538-1003\
C:\RECYCLER\S-1-5-21-1708537768-308236825-839522115-1003\
C:\RECYCLER\S-1-5-21-3078331208-3613578307-661914447-1006\
C:\RECYCLER\S-1-5-21-3078331208-3613578307-661914447-1007\
C:\RECYCLER\S-1-5-21-3078331208-3613578307-661914447-1011\
BTW this is for XP. I dont know if it works in Vista
So Sample:
Sub Button1_Click()
System.io.file.move("C:\Useless.txt", "C:\RECYCLER\S-1-5-21-3078331208-3613578307-661914447-1011\")
End Sub
-
Monday, March 12, 2007 9:06 PM
Omnicoder wrote: It has 5 paths. Use any one of them:
C:\RECYCLER\S-1-5-21-1089551744-1120685985-1162132538-1003\
[snip some paths]
BTW this is for XP. I dont know if it works in Vista
So Sample:
Sub Button1_Click()
System.io.file.move("C:\Useless.txt", "C:\RECYCLER\S-1-5-21-3078331208-3613578307-661914447-1011\")
End Sub
This is not a good solution as it will only work on computers where the folder exactly matches yours and it is very unlikely. The fact that you have 5 folder is another evidence of this as the recycle bins are per user on the computer.
Use the suggested win32 api instead. SHGetSpecialFolderPath().
-
Tuesday, March 13, 2007 2:08 AM
ya this is called hard coded.. so wont work for the thread starter..
Cinov..u shud try evry solution given by us.
-
Tuesday, March 13, 2007 1:06 PM
What about using something like this ? Intelesence give you more options as well .
My
.Computer.FileSystem.DeleteFile("c:\myfile.txt", FileIO.UIOption.AllDialogs, FileIO.RecycleOption.DeletePermanently) -
Wednesday, March 14, 2007 4:21 PM
bdbodger wrote: What about using something like this ? Intelesence give you more options as well .
My
.Computer.FileSystem.DeleteFile("c:\myfile.txt", FileIO.UIOption.AllDialogs, FileIO.RecycleOption.DeletePermanently)How do you get the path to the recycle bin by doing that?
-
Wednesday, March 14, 2007 4:25 PM
Why do you need to that has options to send a file to the recycle bin or delete it permanently . Could this be used it can give you information about the recycle bin .
Dim
value As System.IO.DirectoryInfo = My.Computer.FileSystem.GetDirectoryInfo("recycle bin")*edit no I guess it doesn't execpt to let you know if it exists at the path or not .
-
Wednesday, March 14, 2007 4:49 PM
This might be useful to you:
Public Class RecycleBin<Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.Sequential, Pack:=1)>
Private Structure SHQUERYRBINFO Public cbSize As Integer Public i64Size As Long Public i64NumItems As Long End Structure Public Structure RecycleBinInfo Public Items As Long Public Bytes As Long Public Sub New(ByVal Items As Long, ByVal Bytes As Long) Me.Items = Items Me.Bytes = Bytes End Sub End Structure Private Declare Auto Function SHQueryRecycleBin Lib "shell32.dll" (ByVal pszRootPath As String, ByRef pSHQueryRBInfo As SHQUERYRBINFO) As Integer Private Declare Auto Function SHEmptyRecycleBin Lib "shell32.dll" Alias "SHEmptyRecycleBinA" (ByVal hWnd As IntPtr, ByVal pszRootPath As String, ByVal dwFlags As Integer) As Integer Private Declare Auto Function SHUpdateRecycleBinIcon Lib "shell32.dll" () As Long Public Shared Sub EmptyRecycleBin()SHEmptyRecycleBin(
Nothing, Nothing, 0) End Sub Public Shared Function GetRecycleBinInfo() As RecycleBinInfo Dim items As Long Dim bytes As Long Dim drives() As String = IO.Directory.GetLogicalDrives Dim drive As String For Each drive In drives Dim binInfo As SHQUERYRBINFObinInfo.cbSize = Runtime.InteropServices.Marshal.SizeOf(
GetType(SHQUERYRBINFO))SHQueryRecycleBin(drive, binInfo)
items += binInfo.i64NumItems
bytes += binInfo.i64Size
Next drive Return New RecycleBinInfo(items, bytes) End Function Public Shared Sub OpenRecycleBin() TrySystem.Diagnostics.Process.Start(
"explorer.exe", "::{645FF040-5081-101B-9F08-00AA002F954E}") Catch ex As Exception End Try End Sub End Class -
Thursday, March 15, 2007 7:15 AM
I am still a little confused on how the information is used or displayed after you query the recycle bin and can you explain this line a bit more for me ?
System.Diagnostics.Process.Start("explorer.exe", "::{645FF040-5081-101B-9F08-00AA002F954E}")
-
Thursday, March 15, 2007 7:21 AMIt opens an explorer window displaying the recycle bin.
-
Thursday, March 15, 2007 7:26 AMI could have guessed that but how do you determine the sequence of numbers you used and what is the syntax I notice that it has 2 colens and brackets that is what an id not sure of the termenology .
-
Thursday, March 15, 2007 7:29 AMIt's the CLSID of the recycle bin. I don't actually know why it works like that, I just know it works.
-
Thursday, March 15, 2007 7:32 AMIs there an easy way to determine the CLSID of that and other things is that CLSID the same for every computer to access the recycle bin ?
-
Thursday, March 15, 2007 9:48 AM
Yeah, it's the same on all computers. Don't know about Vista though. Don't know about versions prior to XP either actually :)
Google it, theres a lot of info.
This is a bit of code for a CLSID Lister app I made a while ago:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'HKEY_CLASSES_ROOT\CLSID
Dim key As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey("CLSID")
Dim subKeys() As String = key.GetSubKeyNames
Dim subKey As String
For Each subKey In subKeys
Dim clsidKey As Microsoft.Win32.RegistryKey = key.OpenSubKey(subKey)
Dim text As String = clsidKey.GetValue("", "").ToString & clsidKey.Name
Me.ListBox1.Items.Add(text)
clsidKey.Close()
Next subKey
Me.ListBox1.Sorted = True
End Sub

