Rapid-Q Documentation by Midiprog2000 (c)2005 | Appendix D: QFolder

# QFolder Component

  QFolder is a component to scan a folder (or directory) and all its subfolders for files. The results are stored in two QStringList Objects: one with all subfolder names, and one with all the filenames (including the path). This is a custom component: include "QFolder.inc" to make it available.
  QFolder Properties

  Field | Type | Read/Write | Default Value | Support
  CancelOperation | INTEGER | R |  | W
  | This property is automatically reset to false before every scan operation. Set to 'True' to cancel a scan operation
  FileDate | STRING | R |  | W
  | FileDate of the current scanned file. For use with OnFileFound event
  FileIntTime | INTEGER | R |  | W
  | FileTime of the current scanned file as an integer. For use with OnFileFound event
  FileList | QSTRINGLIST | R |  | W
  | This stringlist contains all files (with full path) after a directory scan
  FileName | STRING | R |  | W
  | Filename of the current scanned file. For use with OnFileFound event
  FileSize | INTEGER | R |  | W
  | FileSize of the current scanned file. For use with OnFileFound event
  FileTime | STRING | R |  | W
  | FileTime of the current scanned file. For use with OnFileFound event
  FolderList | QSTRINGLIST | R |  | W
  | This stringlist contains all directories and subdirectories after a directory scan
  SubFolders | INTEGER | R | True | W
  | Determines whether all subfolders are scanned or not. If true, subfolders are scanned.

  QFolder Methods

  Method | Type | Description | Params | Support
  GetFolderList | FUNCTION (basefolde as string) as long | Scans a directory | 1 | W
  | Scans a directory and all it's subdirectories and stores the results in DirList and FileList QStringList Objects. To retrieve the results from the StringLists, see QStringList Object. Returns true if basedirectory exists, false otherwise.

  QFolder Events

  Event | Type | Occurs when... | Params | Support
  OnFileFound | VOID | Occurs when a file is found while scanning a folder | 0 | W
  OnFolderFound | VOID | Occurs when a folder is found while scanning a folder | 0 | W

  QFolder Examples

      $include "QFolder.inc"

      declare sub loaddir
      declare sub FileFound

      dim flist as Qfolder
          flist.onFileFound = FileFound
          flist.subfolders = 1

      CREATE Form AS QFORM
          Caption = "Subfolder test"
          Width = 667
          Height = 636
          Center
          CREATE RichEdit1 AS QRICHEDIT
              Left = 8
              Top = 8
              Width = 641
              Height = 550
              scrollbars = 2
          END CREATE
          create button as QBUTTON
              caption = "Load program files dir"
              top = 570
              width = 150
              left = 240
              onclick = loaddir
          end create
      END CREATE

      sub loaddir
          Form.caption = "Loading filelist with 'OnFileFound' event (Method 1)"

          if flist.GetFolderList("c:/program files") then
              'Richedit1.clear
              form.caption = "Loading filelist from 'FileList' object (Method 2)"

              'save folderlist and filelist to file
              flist.FolderList.savetofile("c:/FolderList.txt")
              flist.filelist.savetofile("c:/filelist.txt")

              'load filelist in richedit object
              for x = 0 to flist.filelist.itemcount - 1
                  richedit1.addstrings (flist.filelist.item(x))
              next
          else
              showmessage "Directory does not exist"
          end if

          Form.Caption = "Subfolder test - " + str$(flist.filecount) + " files found in " _
                         + str$(flist.Foldercount) + " directories."
      end sub

      sub FileFound
          richedit1.addstrings (flist.filedate + "  " + flist.filetime + "  " + flist.FileName)
      end sub

      form.showmodal