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. Can not open file With QFile Class.

Can not open file With QFile Class.

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 6 Posters 4.9k Views 1 Watching
  • 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.
  • jsulmJ jsulm

    @Gaurav-Badgujar You should not use : in paths/file names especially on Windows

    G Offline
    G Offline
    Gaurav Badgujar
    wrote on last edited by
    #5

    @jsulm
    but its working on "D:\TestFoldler:GauravData:$DATA"
    but this is not working with "\nas\files\gauravFolder:GauravData:$DATA" path.

    jsulmJ 1 Reply Last reply
    0
    • G Gaurav Badgujar

      @jsulm
      but its working on "D:\TestFoldler:GauravData:$DATA"
      but this is not working with "\nas\files\gauravFolder:GauravData:$DATA" path.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #6

      @Gaurav-Badgujar As others said you should either use \\ or /

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      G 1 Reply Last reply
      1
      • jsulmJ jsulm

        @Gaurav-Badgujar As others said you should either use \\ or /

        G Offline
        G Offline
        Gaurav Badgujar
        wrote on last edited by
        #7

        @jsulm used "/" as per above mention comment but still not getting any resolution.

        mrjjM jsulmJ 2 Replies Last reply
        0
        • G Gaurav Badgujar

          @jsulm used "/" as per above mention comment but still not getting any resolution.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #8

          @Gaurav-Badgujar
          Hi
          Try to use a full path and see it it works for you.
          "c:/nas/files/gauravFolder:GauravData:$DATA"
          else
          "./nas/files/gauravFolder:GauravData:$DATA"
          Its just path issue, i think.

          Also again, if on window, the ":" is FORBIDDEN

          1 Reply Last reply
          1
          • G Gaurav Badgujar

            @jsulm used "/" as per above mention comment but still not getting any resolution.

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #9

            @Gaurav-Badgujar What about \\? What exact error do you get (http://doc.qt.io/qt-5/qiodevice.html#errorString)?
            And why do you use characters like : and $ ? You should avoid such characters in paths and file names. Especially :
            : has a special meaning on Windows. Try to save a file in any Windows program using file name with : You will see it does not work.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            1
            • VRoninV Offline
              VRoninV Offline
              VRonin
              wrote on last edited by
              #10

              Another option, given the name of the first folder is nas i can guess it's a network path, they normally start with 2 slashes, not just 1

              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
              ~Napoleon Bonaparte

              On a crusade to banish setIndexWidget() from the holy land of Qt

              G 1 Reply Last reply
              0
              • m.sueM Offline
                m.sueM Offline
                m.sue
                wrote on last edited by m.sue
                #11

                Hi,
                the file names with ":" hide data using ADS (alternate data streams). Strings like ":$DATA" have a special meaning. Normal Explorer and DIR command etc. do not see these files.

                So I doubt Qt can open them for reading/writing; native CreateFile should be able to do so.

                On the other hand: make sure that the file "c:/nas/files/gauravFolder" already exist when you create the data stream file! Here is some code: https://support.microsoft.com/en-us/kb/105763
                -Michael.

                1 Reply Last reply
                1
                • BuckwheatB Offline
                  BuckwheatB Offline
                  Buckwheat
                  wrote on last edited by
                  #12

                  @Gaurav-Badgujar ...

                  There are several things wrong with the path but the :$DATA is the biggest hurdle. It is just not allowed on any M$ operating system. Fixing non-existant paths will be easy but if your file name has special meaning then that could be a problem. Now, if the :$DATA represents some bit of data to write into the file name than ok.

                  The article "Illegal Characters on Various Operating Systems" explains what is legal on most OSes.
                  https://kb.acronis.com/content/39790

                  Dave Fileccia

                  1 Reply Last reply
                  0
                  • VRoninV VRonin

                    Another option, given the name of the first folder is nas i can guess it's a network path, they normally start with 2 slashes, not just 1

                    G Offline
                    G Offline
                    Gaurav Badgujar
                    wrote on last edited by
                    #13

                    @VRonin yes its network path..typo mistake. and it contains two slashes.

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      Gaurav Badgujar
                      wrote on last edited by
                      #14

                      :$DATA its not a path we append this string with path.

                      1 Reply Last reply
                      0

                      • Login

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