How to delete the folder if the folder exist
I would like to delete the folder if the folder exist.. How to do that?
Code:
Dim FSO As Object
Set FSO = CreateObject("scripting.filesystemobject")
KrigProjectPath = interpolProjWorkspace + "\" + TxtKrigRasterWorkspace.Text
If FSO.FolderExists(KrigProjectPath) = True Then
Exit Sub
End If
Re: How to delete the folder if the folder exist
Code:
If Dir$("c:\hack", vbDirectory) <> vbNullString Then
Kill ("c:\hack\*.*")
RmDir ("c:\hack")
Else
MsgBox "directory does not exist"
End If
Re: How to delete the folder if the folder exist
How to delete all files in the folder?
Re: How to delete the folder if the folder exist
I posted an example of that.
Re: How to delete the folder if the folder exist
Kill ("c:\hack\*.*")
RmDir ("c:\hack")
Which one that delete the folder and delete the files?
Re: How to delete the folder if the folder exist
if your using FSO, then do it like this. I just did the same thing today:D ,
Code:
Dim oFolder As scripting.Folder
Dim oFile As scripting.File
Dim fso As scripting.FileSystemObject
Code:
Set fso = New FileSystemObject
If fso.FolderExists("c:\temp\EmailAttachments") Then
Set oFolder = fso.GetFolder("c:\temp\EmailAttachments")
On Error Resume Next
For Each oFile In oFolder.Files
oFile.Delete True 'setting force to true
'deletes read-only file
Next
endif
to delete folder use same principle with:
Re: How to delete the folder if the folder exist
Quote:
Originally Posted by matrik02
Kill ("c:\hack\*.*")
RmDir ("c:\hack")
Which one that delete the folder and delete the files?
Kill deletes the files. RmDir Removes the Directory.