Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RmDir 1

Status
Not open for further replies.

fheyn

Programmer
Mar 22, 2001
198
DE
hi,
below code of function DelTree
pFolder's attribute is &H10
why do I get E 75 with RmDir ?
using the API-functions I encounter same problem

sEntry = Dir(sFolder & "\*.*", vbDirectory)
Do While Len(sEntry) > 0
If sEntry <> "." And sEntry <> ".." Then
If (GetAttr(sFolder & "\" & sEntry) And vbDirectory) = vbDirectory Then
Call DelTree(sFolder & "\" & sEntry)
sEntry = Dir(sFolder & "\*.*", vbDirectory)
Else
Kill sFolder & "\" & sEntry
sEntry = Dir
End If
Else
sEntry = Dir
End If
Loop
RmDir sFolder <------------ error

thanks in advance

 
Using Dir function to implement a Deltree function by deleting each folder recursively does not work because the Dir function does not enumerate all files and folders in general. It normally skips system and hidden files and some files are still left in the folder.

This results in Path/File access error as the folder is not empty when RmDir is called.

You should better choose some other way to delete a folder including its contents.

See thread222-710209 for a couple of implementations of the Deltree function.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top