Delete one file from folder and subfolders

August 11, 2009 at 07:30:13
Specs: Windows XP
I am trying to remove one file that keeps on popping up (creating itself) on a share through Vb.

This is what I have:

Dim fso, EpicIcon
Dim folder, folderCollection, subFolder, fileCollection

EpicIcon = "Epic.lnk"
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder("R:\")
Set folderCollection = folder.SubFolders
Set fileCollection = folder.Files
For Each File In fileCollection
fso.Delete (EpicIcon), True
Next

not really working...


See More: Delete one file from folder and subfolders

Report •


#1
August 11, 2009 at 07:49:04
For Each File In fileCollection
fso.Delete File, True
Next

Report •

#2
August 11, 2009 at 07:53:16
I changed the script a little:

Dim fso, EpicIcon
Dim folder, folderCollection, subFolder, fileCollection


Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder("R:\")
Set folderCollection = folder.SubFolders
For Each Folder In folderCollection
Set fileCollection = folder.Files
For Each File In fileCollection
EpicIcon = folder & "\Desktop\Epic.lnk"
fso.DeleteFile (EpicIcon), True
Next
Next


Report •

#3
August 11, 2009 at 11:32:35
There is a 'Programming' forum.

Report •

Related Solutions


Ask Question