Previous - sysFolderCreate Section Home - File System Next - sysFolderTemp


sysFolderDelete ( )

Deletes an empty existing directory

Usage:

sysFolderDelete (object me, string folderPath )

Parameters:

folderPath (string) - a string specifying the path to an existing directory

Returns:

(integer) - The success code

Example:

-- example is a recursive function
-- demonstrates how to properly delete all files within a folder
-- will delete all files ( including read-only files ) and delete all sub folders

On folderDelete ( strFolderPath )
  -- strFolderPath should contain a trailing slash
  
  xtRose = xtra("rosetta").new()
  
  -- check if there are files in this folder
  strLstFiles = xtRose.sysFileList( strFolderPath & "*.*" )
  If ( strLstFiles.count > 0 ) Then
    -- delete each file individually
    nFiles = strLstFiles.count
    Repeat with i = 1 to nFiles
      strFileName = strLstFiles[i]
      
      strPath = strFolderPath & strFileName
      If ( xtRose.sysFileAttribute( strFolderPath & strFileName ) contains "r" ) Then
        -- clear the read only attributes
        xtRose.sysFileSetAttribute( strFolderPath & strFileName, EMPTY )
      End If
      
      -- delete the file
      xtRose.sysFileDelete( strFolderPath & strFileName )
    End Repeat
  End If
  
  -- check if there are sub-folders in this folder
  strLstFolders = xtRose.sysFolderList( strFolderPath )
  If ( strLstFolders.count > 0 ) Then
    -- recursively delete all sub folders
    folderDelete( strFolderPath & strLstFolders &"\" )
  End If
  
End

Notes:


Previous - sysFolderCreate Section Home - File System Next - sysFolderTemp