Problems with Open-Source Downloads read https://www.qt.io/blog/problem-with-open-source-downloads and https://forum.qt.io/post/638946

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?



  • You can try use

    var files = QDesktopServices.findFiles("@InstallerDirPath@", "README2.txt");
    

Log in to reply