Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Doesn't show all the files in system("dir")
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 543 Views
  • 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 Offline
    S Offline
    saeidparand
    wrote on last edited by
    #1

    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?

    JonBJ 1 Reply Last reply
    0
    • S saeidparand

      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?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @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
      0
      • JonBJ 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 Offline
        S Offline
        saeidparand
        wrote on last edited by
        #3

        @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
        0
        • JonBJ 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 Offline
          S Offline
          saeidparand
          wrote on last edited by
          #4

          @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 .

          JonBJ 1 Reply Last reply
          0
          • S saeidparand

            @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 .

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

            @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
            0
            • JonBJ JonB

              @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 Offline
              S Offline
              saeidparand
              wrote on last edited by
              #6

              @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
              1

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved