Monday, February 7, 2011

Fucntion to create folder and check if the folder is exists or not

' Fucntion to create folder and check if the folder is exists or not.
'This Function can help to create run time Framework Folder.
Function CreateFolderStruct(FolderPath)

      'Create Folder
      On Error Resume Next
      dim objFSO
      strFldr=FolderPath
      set objFSO=CreateObject("Scripting.FileSystemObject")
      if isFolderExists(FolderPath) = "False" then
              objFSO.CreateFolder(strFldr)
     end if
     set objFSO=Nothing

End Function

Function isFolderExists(FolderPath)
      On Error Resume Next
      dim objFSO
      set objFSO=CreateObject("Scripting.FileSystemObject")
      if objFSO.FolderExists(FolderPath) then
            isFolderExists = "True"
      else
            isFolderExists = "False"
      end if
      set objFSO=Nothing
End Function

No comments: