I am trying to write a function that will delete all the files in a directory. I got a delete program from the FAQ section. The only problem with it is it only deletes one file at a time. I need it to delete 24 files.
The problem is the function will only delete the last file in my group. What can I do to make my program loop to delete all the programs?
My code is as follows:
Function DeleteFile()
Dim fso
Dim file As String
'file = "C:\My Data\Eracent\Audit File\My Documents" ' change to match the file w/Path
'file = "C:\My Data\Eracent\Audit File\My Documents" ' change to match the file w/Path
'file = "C:\My Data\Eracent\Audit File\T_AIXModels_LUT" ' change to match the file w/Path
'file = "C:\My Data\Eracent\Audit File\T_BS_LUT" ' change to match the file w/Path
'file = "C:\My Data\Eracent\Audit File\T_pa_lut" ' change to match the file w/Path
'file = "C:\My Data\Eracent\Audit File\T_Packages.fmt" ' change to match the file w/Path
'file = "C:\My Data\Eracent\Audit File\T_Packages.txt" ' change to match the file w/Path
'file = "C:\My Data\Eracent\Audit File\T_PAR_LUT" ' change to match the file w/Path
'file = "C:\My Data\Eracent\Audit File\T_PkgType_LUT.txt" ' change to match the file w/Path
'file = "C:\My Data\Eracent\Audit File\T_POR_LUT" ' change to match the file w/Path
'file = "C:\My Data\Eracent\Audit File\T_POR_LUT.txt" ' change to match the file w/Path
'file = "C:\My Data\Eracent\Audit File\T_Processor_LUT" ' change to match the file w/Path
'file = "C:\My Data\Eracent\Audit File\T_ProductProcess_LUT" ' change to match the file w/Path
'file = "C:\My Data\Eracent\Audit File\T_ProductProcess_LUT.txt" ' change to match the file w/Path
'file = "C:\My Data\Eracent\Audit File\T_SMBSPN_LUT" ' change to match the file w/Path
'file = "C:\My Data\Eracent\Audit File\T_SMBSPV_LUT" ' change to match the file w/Path"
'file = "C:\My Data\Eracent\Audit File\T_SNMPMakes_LUT" ' change to match the file w/Path"
'file = "C:\My Data\Eracent\Audit File\T_SNMPModels_LUT" ' change to match the file w/Path"
'file = "C:\My Data\Eracent\Audit File\T_SWMfg.txt" ' change to match the file w/Path"
'file = "C:\My Data\Eracent\Audit File\T_SWProducts.fmt" ' change to match the file w/Path"
'file = "C:\My Data\Eracent\Audit File\T_SWProducts.txt" ' change to match the file w/Path"
'file = "C:\My Data\Eracent\Audit File\T_UFPAR_LUT" ' change to match the file w/Path"
'file = "C:\My Data\Eracent\Audit File\T_UPAR_LUT" ' change to match the file w/Path"
'file = "C:\My Data\Eracent\Audit File\Update.exe" ' change to match the file w/Path"
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(file) Then
fso.DeleteFile file, True
Else
MsgBox file & " does not exist or has already been deleted!" _
, vbExclamation, "File not Found"
End If
End Function
Tom
The problem is the function will only delete the last file in my group. What can I do to make my program loop to delete all the programs?
My code is as follows:
Function DeleteFile()
Dim fso
Dim file As String
'file = "C:\My Data\Eracent\Audit File\My Documents" ' change to match the file w/Path
'file = "C:\My Data\Eracent\Audit File\My Documents" ' change to match the file w/Path
'file = "C:\My Data\Eracent\Audit File\T_AIXModels_LUT" ' change to match the file w/Path
'file = "C:\My Data\Eracent\Audit File\T_BS_LUT" ' change to match the file w/Path
'file = "C:\My Data\Eracent\Audit File\T_pa_lut" ' change to match the file w/Path
'file = "C:\My Data\Eracent\Audit File\T_Packages.fmt" ' change to match the file w/Path
'file = "C:\My Data\Eracent\Audit File\T_Packages.txt" ' change to match the file w/Path
'file = "C:\My Data\Eracent\Audit File\T_PAR_LUT" ' change to match the file w/Path
'file = "C:\My Data\Eracent\Audit File\T_PkgType_LUT.txt" ' change to match the file w/Path
'file = "C:\My Data\Eracent\Audit File\T_POR_LUT" ' change to match the file w/Path
'file = "C:\My Data\Eracent\Audit File\T_POR_LUT.txt" ' change to match the file w/Path
'file = "C:\My Data\Eracent\Audit File\T_Processor_LUT" ' change to match the file w/Path
'file = "C:\My Data\Eracent\Audit File\T_ProductProcess_LUT" ' change to match the file w/Path
'file = "C:\My Data\Eracent\Audit File\T_ProductProcess_LUT.txt" ' change to match the file w/Path
'file = "C:\My Data\Eracent\Audit File\T_SMBSPN_LUT" ' change to match the file w/Path
'file = "C:\My Data\Eracent\Audit File\T_SMBSPV_LUT" ' change to match the file w/Path"
'file = "C:\My Data\Eracent\Audit File\T_SNMPMakes_LUT" ' change to match the file w/Path"
'file = "C:\My Data\Eracent\Audit File\T_SNMPModels_LUT" ' change to match the file w/Path"
'file = "C:\My Data\Eracent\Audit File\T_SWMfg.txt" ' change to match the file w/Path"
'file = "C:\My Data\Eracent\Audit File\T_SWProducts.fmt" ' change to match the file w/Path"
'file = "C:\My Data\Eracent\Audit File\T_SWProducts.txt" ' change to match the file w/Path"
'file = "C:\My Data\Eracent\Audit File\T_UFPAR_LUT" ' change to match the file w/Path"
'file = "C:\My Data\Eracent\Audit File\T_UPAR_LUT" ' change to match the file w/Path"
'file = "C:\My Data\Eracent\Audit File\Update.exe" ' change to match the file w/Path"
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(file) Then
fso.DeleteFile file, True
Else
MsgBox file & " does not exist or has already been deleted!" _
, vbExclamation, "File not Found"
End If
End Function
Tom