#194387 - 2009-06-24 01:59 PM
visual basic help
|
BradV
Seasoned Scripter
  
Registered: 2006-08-16
Posts: 685
Loc: Maryland, USA
|
Does anyone know what:
is setting the constant to?
|
Top
|
|
|
|
#194389 - 2009-06-24 02:37 PM
Re: visual basic help
[Re: BradV]
|
BradV
Seasoned Scripter
  
Registered: 2006-08-16
Posts: 685
Loc: Maryland, USA
|
OK, I was prompted by the empty recycle bin question in the basic forum. I didn't like that he was using a batch file to delete the entire bin and then remake it. So, I did a quick search and found:
A simple script to clear the recycle bin
===
Set fso = CreateObject("Scripting.FileSystemObject")
Const RECYCLE_BIN = &Ha&
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(RECYCLE_BIN)
Set objFolderItems = objFolder.Items
For i = 0 to objFolderItems.Count - 1
fso.DeleteFile objFolderItems.Item(i).Path, 1
Next
===
I translated that as:
Dim $objFSO, $intRB, $objShell, $objFolder, $objFoldItm, $i
$objFSO = CreateObject("Scripting.FileSystemObject")
$intRB = 10
$objShell = CreateObject("Shell.Application")
$objFolder = $objShell.NameSpace($intRB)
$objFoldItm = $objFolder.Items
For $i = 0 To $objFoldItm.Count-1
$objFSO.DeleteFile $objFoldItm.Item($i).Path,1
Next
Everything seems to work up until the delete line. Any thoughts?
|
Top
|
|
|
|
#194391 - 2009-06-24 03:28 PM
Re: visual basic help
[Re: Mart]
|
Jochen
KiX Supporter
   
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
|
Top
|
|
|
|
#194401 - 2009-06-24 04:40 PM
Re: visual basic help
[Re: Mart]
|
BradV
Seasoned Scripter
  
Registered: 2006-08-16
Posts: 685
Loc: Maryland, USA
|
OK, I think this is pretty close to a final solution:
Dim $objFSO, $intRB, $objShell, $objFolder, $objFoldItm, $i
$objFSO = CreateObject("Scripting.FileSystemObject")
$intRB = 10
$objShell = CreateObject("Shell.Application")
$objFolder = $objShell.NameSpace($intRB)
$objFoldItm = $objFolder.Items
For $i = 0 to $objFoldItm.Count - 1
If $objFSO.FileExists($objFoldItm.Item($i).Path)
$objFSO.DeleteFile($objFoldItm.Item($i).Path, 1)
Else
If $objFSO.FolderExists($objFoldItm.Item($i).Path)
$objFSO.DeleteFolder($objFoldItm.Item($i).Path, 1)
Endif
Endif
Next
|
Top
|
|
|
|
#194406 - 2009-06-24 05:22 PM
Re: visual basic help
[Re: BradV]
|
BradV
Seasoned Scripter
  
Registered: 2006-08-16
Posts: 685
Loc: Maryland, USA
|
OK, put it in the UDF forum. Let me know if I made any typos!
Empty Recycle Bin UDF
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 284 anonymous users online.
|
|
|