Altaf Patni
asked on
USING VB6.0 HOW TO DELETE %TEMP% FILES.?
Hi i wanted to delete files from %temp% folder
Using VB6.0
Using VB6.0
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@stergium
Tried ur suggestion,
"Run Time Error 53
File Not Found"
Tried ur suggestion,
"Run Time Error 53
File Not Found"
ASKER
Thanks for reply..
@angelIII
I tried your suggestion,
and i write some code as bellow. please check.
now some of files deleting but now every files and folders whatever in temp folder.
so how to delete every thing from %temp% folder..
@angelIII
I tried your suggestion,
and i write some code as bellow. please check.
now some of files deleting but now every files and folders whatever in temp folder.
so how to delete every thing from %temp% folder..
Dim fso As Object
i = 0
ReDim filelist(0)
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(GetTmpPath)
For Each f1 In f.Files
i = i + 1
ReDim Preserve filelist(i)
Set filelist(i) = f1
Kill f1
Next
you can do like this:
Dim fso As Object
i = 0
ReDim filelist(0)
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(GetTmpPath)
For Each f1 In f.Files
f1.Delete
Next
ASKER
Files is deleting but
folder can't
i want to delete folders withing temp folder
folder can't
i want to delete folders withing temp folder
ASKER
ok Problem solved
Thanks angelIII
Thanks angelIII
If oFs.FolderExists(FolderSpec) Then
Set oFolder = oFs.GetFolder(FolderSpec)
On Error Resume Next
For Each oFolder In oFolder.SubFolders
oFolder.Delete True 'setting force to true
Next
DeleteAllFiles = oFolder.SubFolders.Count = 0
End If
try using
Dim fso As Object
Set fso = CreateObject("Scripting.Fi
fso.Deletefile ("%temp%\*")
and please feedback