Create and delete folders
In those examples we will create and delete a subdirectory within cgi-bin directory in our site. Many often we will have permission to perform this operations only in this directory.
 

Create subdirectory "myfiles"

<%
Foldertocreate=server.mappath("\") &"/cgi-bin/myfiles"  

Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateFolder(Foldertocreate) 
Set fs=nothing
%>
Done

Delete subdirectory "myfiles"

<%
Foldertodelete=server.mappath("\") &"/cgi-bin/myfiles"  

Set fs = CreateObject("Scripting.FileSystemObject")
fs.DeleteFolder(Foldertodelete) 
Set fs=nothing
%>
Done

Delete a folder only in case it exits (to avoid errors)

<%
Foldertodelete=server.mappath("\") &"/cgi-bin/myfiles"  

Set fs = CreateObject("Scripting.FileSystemObject")
   if fs.FolderExists("c:\temp") then
      fs.DeleteFolder "c:\temp"
   end if
Set fs=nothing
%>
Done


AspTutorial.info.