Previous - sysFolderExist Section Home - File System Next - sysFolderCreate


sysFolderList ( )

Obtains a list of sub folders within a directory

Usage:

sysFolderList (object me, string folderPath )

Parameters:

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

Returns:

(list of strings) - A list of files matching the file spec.

Example1:

-- lists the contents of the Director 8.5 folder
PROGRAM_FILES_FOLDER = 8
xtRose = xtra("Rosetta").new( )
strProgFilesPath = xtRose.sysFolderSpecial( PROGRAM_FILES_FOLDER, 1)
strLst_files = xtRose.sysFolderList( strProgFilesPath&"\Macromedia\Director 8.5\" )

Example2:

-- 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 - sysFolderExist Section Home - File System Next - sysFolderCreate