|
-
Apr 1st, 2008, 07:50 AM
#1
Thread Starter
Frenzied Member
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
-
Apr 1st, 2008, 07:56 AM
#2
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
-
Apr 1st, 2008, 08:03 AM
#3
Thread Starter
Frenzied Member
Re: How to delete the folder if the folder exist
How to delete all files in the folder?
-
Apr 1st, 2008, 08:05 AM
#4
Re: How to delete the folder if the folder exist
I posted an example of that.
-
Apr 1st, 2008, 08:08 AM
#5
Thread Starter
Frenzied Member
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?
-
Apr 1st, 2008, 08:11 AM
#6
PowerPoster
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 ,
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:
Last edited by Nitesh; Apr 1st, 2008 at 08:13 AM.
Reason: adding info
-
Apr 1st, 2008, 09:16 AM
#7
Re: How to delete the folder if the folder exist
 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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|