ZeroEffect Posted October 22, 2005 Posted October 22, 2005 Um? How can I do this. :confused: I have found all these great things in .Net that has made moving, deleting, copying files easier. All the special folders are easy to find but why is it hard to move or send a file to the recycle bin with or without the conferimation diolog. Any thoughts Thanks ZeroEffect Quote If you can't find it, Build It. There is no place Like 127.0.0.1 also don't forget 1 + 1 = 10
ZeroEffect Posted October 22, 2005 Author Posted October 22, 2005 Update Well I found this but it is just prompting for the delete. Imports System.IO Private Structure SHFILEOPSTRUCT Dim hwnd As Integer Dim wFunc As Integer Dim pFrom As String Dim pTo As String Dim fFlags As Short Dim fAnyOperationsAborted As Boolean Dim hNameMappings As Integer Dim lpszProgressTitle As String End Structure Private Const FO_DELETE As Short = &H3S Private Const FOF_ALLOWUNDO As Short = &H40S Private Const FOF_NOCONFIRMATION As Short = &H10S Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (ByRef lpFileOp As SHFILEOPSTRUCT) As Integer Public Function Recycle(ByRef sPath As String) As Integer Dim FileOp As SHFILEOPSTRUCT If Not File.Exists(sPath) Then MsgBox("Could not find " & sPath & "." & vbCrLf _ & "Please verify the path.") Recycle = -1 Exit Function End If With FileOp .wFunc = FO_DELETE .fFlags = FOF_ALLOWUNDO 'Or FOF_NOCONFIRMATION .pFrom = sPath & vbNullChar .pTo = vbNullChar End With Try SHFileOperation(FileOp) Catch ex As Exception MsgBox(ex.Message) End Try Recycle = 0 End Function Any Thoughts ZeroEffect Quote If you can't find it, Build It. There is no place Like 127.0.0.1 also don't forget 1 + 1 = 10
Nate Bross Posted October 22, 2005 Posted October 22, 2005 I don't know if there is a way to bypass the "Are you Sure?" dialog when deleting a file. You can turn the dialog off from the properties of the recycling bin. I don't know how to do it programmatically. Maybe a registry key? Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
Nate Bross Posted October 22, 2005 Posted October 22, 2005 I believe that you might be able to use this registry information to disable the Delete Conformation Dialog. EDIT-This tweak just disables the recycling bin all together. Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
Nate Bross Posted October 22, 2005 Posted October 22, 2005 After doing a bit more research I found this. I hope this helps you. Turns off the recycle bin delete confirmation for all drives [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer] "ShellState"=hex:24,00,00,00,37,a8,01,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 01,00,00,00,0d,00,00,00,00,00,00,00,02,00,00,00 Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
Leaders snarfblam Posted October 23, 2005 Leaders Posted October 23, 2005 Generally, I would say that if the file you are deleting isn't a file that the user needs to know about then you should not worry about sending it to the recycle bin; just delete it. If it is a file that needs to be sent to the recycle bin in case the user will want to recover it, a message to the user confirming the delete might be appropriate so that the user knows what is going on. I hope you aren't going do distribute a program that disables the "Are you sure" prompt for deleting the files. Even if it is only temporary, in the event of an error in your application this can cause very undesirable behavior on the end user's machine. I wouldn't wan't such software running on my PC, and depending on how it is programmed, the user might accidentally delete other files without even realizing it any time your program is running. By the look of things, that registry setting may alter other settings as well. Unless you know for a fact that this is not the case, I recommend doing more research on that registry key. Quote [sIGPIC]e[/sIGPIC]
ZeroEffect Posted October 23, 2005 Author Posted October 23, 2005 The Goal Generally, I would say that if the file you are deleting isn't a file that the user needs to know about then you should not worry about sending it to the recycle bin; just delete it. If it is a file that needs to be sent to the recycle bin in case the user will want to recover it, a message to the user confirming the delete might be appropriate so that the user knows what is going on. I hope you aren't going do distribute a program that disables the "Are you sure" prompt for deleting the files. Even if it is only temporary, in the event of an error in your application this can cause very undesirable behavior on the end user's machine. I wouldn't wan't such software running on my PC, and depending on how it is programmed, the user might accidentally delete other files without even realizing it any time your program is running. By the look of things, that registry setting may alter other settings as well. Unless you know for a fact that this is not the case, I recommend doing more research on that registry key. First off thanks for the replys! :) Basicly I am writing a program to automate the archiving of files. I have a folder I have to mannually archive everyweek. Leave the newest two weeks move the third to an archive folder. In the archive folder delete the oldest weeks worth of files. I wanted to have the option of just sending the files to the recycle bin built into the application. Now with the code in my earlier post I can supress the confirmation prompt (app only) but it deletes the files and the prompt that is displayed when it is not supressed is the one when you hold down the "Shift" key and hit delete while a file is selected. The option of sending the file to the recycle bin doesn't come up. I have the whole thing done other than the option for the recycle bin. Any other thoughts, I do think this wilol help more people that just me. Thanks for all the input from everyone. ZeroEffect Quote If you can't find it, Build It. There is no place Like 127.0.0.1 also don't forget 1 + 1 = 10
jo0ls Posted October 23, 2005 Posted October 23, 2005 http://www.codeproject.com/shell/recyclebin.asp c++ , but good explanations of what he's doing. Quote
ZeroEffect Posted October 23, 2005 Author Posted October 23, 2005 http://www.codeproject.com/shell/recyclebin.asp c++ , but good explanations of what he's doing. I think I might have to read this a few times, I don't know C++. So it's losing me a little. I also don't have C++ so the source files are no good to me. I do think the artical is good I just need to get some more knowledge before I'm able to under stand it. Does any one know of a VB.Net example? Thanks for the help ZeroEffect Quote If you can't find it, Build It. There is no place Like 127.0.0.1 also don't forget 1 + 1 = 10
Leaders dynamic_sysop Posted October 24, 2005 Leaders Posted October 24, 2005 using the following ... .fFlags = FOF_ALLOWUNDO Or FOF_NOCONFIRMATION sends files silently to the recycle bin for me :) . Quote
Leaders snarfblam Posted October 25, 2005 Leaders Posted October 25, 2005 Just a thought: If you want the files to be recoverable, why not simply remove them to your [application's] own backup folder instead of cluttering the recycle bin? Quote [sIGPIC]e[/sIGPIC]
ZeroEffect Posted October 25, 2005 Author Posted October 25, 2005 Thanks Just a thought: If you want the files to be recoverable' date=' why not simply remove them to your [application's'] own backup folder instead of cluttering the recycle bin? I think that might be my best option for right now. Refering to the post to above this one. Those flags with the code above still bypassed the recycle bin. :( Thanks for all you help. ZeroEffect Quote If you can't find it, Build It. There is no place Like 127.0.0.1 also don't forget 1 + 1 = 10
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.