file delete routine is intermittent
- From: "Steve Easton" <admin@xxxxxxxxxxxxx>
- Date: Tue, 19 Apr 2005 11:28:33 -0400
Having problems with the following trying to move files to the recycle bin.
It doesn't move all of the files. Any ideas??
Private Function FilesCountAll(sSource As String, sFileType As String) As Long
Dim WFD As WIN32_FIND_DATA
Dim hFile As Long
Dim file2delete As Variant
Dim filenames As New Collection
Dim shf As SHFILEOPSTRUCT
'Start searching for files in sSource by obtaining a file
'handle to the first file matching the filespec passed
hFile = FindFirstFile(sSource & sFileType, WFD)
If hFile <> INVALID_HANDLE_VALUE Then
'must have at least one, so ...
Do
'find the next file and increment the counter
If (Asc(WFD.cFileName) <> vbDot) Then FilesCountAll = FilesCountAll + 1
If (Asc(WFD.cFileName) <> vbDot) Then sFile = sSource & WFD.cFileName & vbNullChar
If (Asc(WFD.cFileName) <> vbDot) Then file2delete = sFile
If (Asc(WFD.cFileName) <> vbDot) Then filenames.Add file2delete
Loop Until FindNextFile(hFile, WFD) = 0
FOF_FLAGS = GetOptionFlags()
For i = 1 To filenames.Count
file2delete = filenames(i)
With shf
.wFunc = FO_DELETE 'action to take place
.pFrom = file2delete 'the file to delete
.fFlags = FOF_FLAGS 'special flags (FOF_*)
End With
Call SHFileOperation(shf)
Next i
End If
'Close the search handle
'and exit the routine if the folder is empty
Call FindClose(hFile)
End Function
The folder location ( sSource ) is determined in another function and verified to exist before this
function is called.
sFileType is set to *.*
The option flags are contained in the getoptionflags function.
tyia
--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
.
- Follow-Ups:
- Re: file delete routine is intermittent
- From: Randy Birch
- Re: file delete routine is intermittent
- From: MikeD
- Re: file delete routine is intermittent
- From: Jonathan Wood
- Re: file delete routine is intermittent
- Prev by Date: Re: Interrupting program execution
- Next by Date: Wake-up monitor
- Previous by thread: System tray icons and callback messages
- Next by thread: Re: file delete routine is intermittent
- Index(es):
Relevant Pages
|