getFilesFromDirectory()

Adds all files names from given directory 'absolutePath' to 'files'.

Synopsis

void getFilesFromDirectory(dyn_string &files, const string absolutePath, const string relativePath, string pattern = "*");

Parameters

Parameter Meaning
files List of files to add the new file names to.
absolutePath Directory to look for files.
relativePath Is used as path to build the file list.
pattern

File pattern used for searching file names. The default value is all ("*"). Pattern is case-sensitive also for Windows platform. Pattern is only applied to file names, not directory names.

Example for search either *.pnl or *.xml: *.[px][nm][l] (would also find *.pml;*.xnl etc.) since "one" of the characters in square brackets is searched. For details, see patternMatch().

Return value

-

Description

Adds filenames to parameter 'files' from the given directory 'absolutePath'.

Example

The following example creates a file list of the files in the directory "dplist" and uses the relative path as path for the file list. The list is output after creating it.

  1. main(mapping event)
    
    
    {
    
    
      dyn_string fils;
    
    
      dyn_string pat = "*.[d][pm][l]";
    
    
      const string absPath = "D:/WinCC_OA_Projects/WinCCOA_Proj/dplist";
    
    
      const string relPath = "D:/WinCC_OA_Projects/WinCCOA_Proj/dplist";
    
    
      getFilesFromDirectory(fils, absPath, relPath);
    
    
      DebugN("Files list:", fils);
    
    
    }

Assignment

File function

Availability

CTRL, UI