Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Forum Updated on Feb 6th

    Solved Doesn't show all the files in system("dir")

    General and Desktop
    2
    6
    196
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      saeidparand last edited by

      Hi dear friends.
      I have 6 files in C://Windows/System32/ras
      when I run cmd.exe and type dir it shows all the 6 files but when I use these syntax in QT :
      QDir::setCurrent("C://Windows/System32/ras");
      system("dir");
      It shows only 4 files. why?

      JonB 1 Reply Last reply Reply Quote 0
      • JonB
        JonB @saeidparand last edited by JonB

        @saeidparand
        Probably something to do with 32- vs 64-bit-ness, or permissions, or the fact that it's in Windows/System32 which Windows has special handling for, or something like that; who knows given that you don't show the output.

        However, it's a bit irrelevant as you should not be using either system(), nor should you use dir as a command to find out what files exist in any case. Look at https://doc.qt.io/qt-5/qdir.html#entryList-1 or https://doc.qt.io/qt-5/qdir.html#entryInfoList-1 and start from there.

        S 2 Replies Last reply Reply Quote 0
        • S
          saeidparand @JonB last edited by

          @jonb
          this is out put form QT :
          07/14/2009 07:50 AM <DIR> .
          07/14/2009 07:50 AM <DIR> ..
          06/11/2009 02:09 AM 735 cis.scp
          06/11/2009 02:09 AM 14,529 pad.inf
          06/11/2009 02:09 AM 2,817 pppmenu.scp
          06/11/2009 02:09 AM 6,235 switch.inf
          4 File(s) 24,316 bytes
          2 Dir(s) 40,612,597,760 bytes free

          and this is out put form CMD.exe :
          08/28/2019 04:54 PM <DIR> .
          08/28/2019 04:54 PM <DIR> ..
          06/11/2009 01:29 AM 735 cis.scp
          06/11/2009 01:29 AM 14,529 pad.inf
          06/11/2009 01:29 AM 2,817 pppmenu.scp
          06/11/2009 01:29 AM 6,235 switch.inf
          08/28/2019 01:59 PM 44,575 temp.pbk
          08/28/2019 01:58 PM 44,575 temp.txt
          6 File(s) 113,466 bytes
          2 Dir(s) 40,612,581,376 bytes free

          1 Reply Last reply Reply Quote 0
          • S
            saeidparand @JonB last edited by

            @jonb
            as you can see , It doesn't show temp.txt and temp.pbk
            I must use system() , because I want run cmd.exe in background my software and run some windows command .

            JonB 1 Reply Last reply Reply Quote 0
            • JonB
              JonB @saeidparand last edited by

              @saeidparand
              Purely at a guess, since they are temp files, and have been created right now, they do not exist when you try from your Qt program but they do when you try from the Command Prompt, or they are appearing on a schedule, or something. I do not believe there will be any difference between the two different ways of running dir (except for possibly the permissions I mentioned).

              S 1 Reply Last reply Reply Quote 0
              • S
                saeidparand @JonB last edited by

                @jonb
                solved but It was not about the level of access.
                I set Run Environment in System Environment in QT Creator.
                thanks for your suggestion.

                1 Reply Last reply Reply Quote 1
                • First post
                  Last post