Friday, August 12, 2016

Classic ASP - Create Folder Structure

It is common that we have almost forgotten classic asp but what if you got some modification to do. Here is how we can create a folder structure if not exists...
   Set FS = Server.CreateObject("Scripting.FileSystemObject")       
   'Create folder if not exists  
   dim pathCounter  
   dim arrUploadPath
   dim newPath  
   newPath = ""  
   pathCounter=0  
   arrUploadPath = Split(uploadPath,"\")  
   For Each item in arrUploadPath  
     If Trim(item) <> "" Then  
       newPath = newPath + item + "\"  
       If pathCounter <> 0 Then          
         If Not FS.FolderExists(newPath) Then              
          FS.CreateFolder(newPath)            
         End If  
       End If  
       pathCounter = pathCounter + 1    
     End If         
   Next