Re: Remove folders
- From: "Randy Birch" <rgb_removethis@xxxxxxxx>
- Date: Wed, 15 Mar 2006 21:16:19 -0500
Yes, as long as you're not in that folder ...
'works
Private Sub Command12_Click()
Dim sTopFolderToDelete As String
Dim shfop As SHFILEOPSTRUCT
sTopFolderToDelete = "D:\test\level 1\level 2\level 3"
With shfop
.wFunc = FO_DELETE
.pFrom = sTopFolderToDelete & vbNullChar
.fFlags = FOF_ALLOWUNDO Or _
FOF_NOCONFIRMATION
End With
Call SHFileOperation(shfop)
End Sub
'doesn't work
Private Sub Command12_Click()
Dim sTopFolderToDelete As String
Dim shfop As SHFILEOPSTRUCT
sTopFolderToDelete = "D:\test\level 1\level 2\level 3"
ChDrive "d:" '<<<<<<<<<<
ChDir sTopFolderToDelete '<<<<<<<<<<
With shfop
.wFunc = FO_DELETE
.pFrom = sTopFolderToDelete & vbNullChar
.fFlags = FOF_ALLOWUNDO Or _
FOF_NOCONFIRMATION
End With
'perform the operation
Call SHFileOperation(shfop)
End Sub
--
Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/
Please reply to the newsgroups so all can participate.
"MikeD" <nobody@xxxxxxxxxxx> wrote in message
news:uCaEP4ISGHA.1844@xxxxxxxxxxxxxxxxxxxxxxx
"Karl E. Peterson" <karl@xxxxxxxx> wrote in message
news:ukwzuZFSGHA.1236@xxxxxxxxxxxxxxxxxxxxxxx
Harold Druss wrote:
My question is if how could I remove all files and folders beyond a
given path.
Assuming you're not writing the Next Great Virus, the answer would be
"methodically, from the bottom up." There are any number of samples on
drilling through the file system. For a pure VB answer, see
http://vb.mvps.org/samples/DirDrill
Isn't the OP just talking about subfolders? Doesn't SHFileOperation delete
them as well? Might need to specify some options for it, such as the one
for answering yes to all prompts.
--
Mike
Microsoft MVP Visual Basic
.
- Follow-Ups:
- Re: Remove folders
- From: Harold Druss
- Re: Remove folders
- References:
- Remove folders
- From: Harold Druss
- Re: Remove folders
- From: Karl E. Peterson
- Re: Remove folders
- From: MikeD
- Remove folders
- Prev by Date: Re: How to retrieve data from Type?
- Next by Date: Re: Remove folders
- Previous by thread: Re: Remove folders
- Next by thread: Re: Remove folders
- Index(es):