Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to check if a file exists with the QT Installer Framework?



  • I want to check file exist.

    I created folder: %temp%\test (C:\Users\me\AppData\Local\Temp\test)
    I copied README2.txt to the folder.

    And if there the file in the folder, I want to copy them to TargetDir.

    So I did it like the code below.

    if(installer.fileExists("@InstallerDirPath@/README2.txt")){
                console.log("Find File");
                component.addOperation("Copy", "@InstallerDirPath@/README2.txt", "@TargetDir@/README2.txt");
    }
    else
                console.log("Can't Find File");
    

    InstallerDirPath: The directory that contains the installer application executable.

    However, even if there is a README2.txt file in the folder, the file cannot be found.

    How can I check if the file exists and copy the file?


Log in to reply