Working with directories can be practical when planning where to put project files, created from raw data for example.
In the example below, just a simple script is used to show the concept.
At first, a directory object should be created via the method new Dir;. This directory object has potential access to the file system of the computer. It can see which files are located in certain directories, provide a list with files and remove files.
In the example below, the user is asked to choose a directory by a FileDialog. This directory is set in the directory object 'BVprojectDir'.
Next, a list with files is asked from the directory via the command Entrylist(). Which files are chosen, depends from the filter that is entered by the user.
This can be any extension. When no file with that extension exists in that directory, an empty list is returned.
The list is shown to the user via a message box. Because the file list is not saved in a plain text object, but in a general object type (QVariant), the list is converted to text with the toString() method.
The following code was used to achieve this:
>>
Next:
4e. Running
external programs
Index