Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-76228

QSaveFile unable to open UNC path to write on Windows

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.11.1
    • Fix Version/s: None
    • Component/s: Core: I/O
    • Labels:
    • Environment:
      tested on Windows 7 and Windows 10
    • Platform/s:
      Windows

      Description

      QFile can successfully open a file to write with a UNC path. QSaveFile cannot open the same file. For example:

          QString path = QString( "\\\\drive\\dir\\myfile.txt" );
          qDebug() << "path=" << path;
          QFile f2( path );
          if ( f2.open( QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text ) )
          {
              qDebug() << "QFile ok";
          }
          else
          {
              qDebug() << "QFile f.error()=" << f2.error();
              qDebug() << "QFile f.errorString()=" << f2.errorString();
          }
      
          QSaveFile f( path );
          if ( f.open( QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text ) )
          {
              qDebug() << "QSaveFile ok";
          }
          else
          {
              qDebug() << "QSaveFile f.error()=" << f.error();
              qDebug() << "QSaveFile f.errorString()=" << f.errorString();
          }
      
      

      Returns:

      path= "\\\\drive\\dir
      myfile.txt"
      QFile ok
      QSaveFile f.error()= 5
      QSaveFile f.errorString()= "The system cannot find the path specified."

        Attachments

        1. qtbug76228_diag.diff
          4 kB
        2. qtbug76228.zip
          2 kB

          Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Activity

              People

              • Assignee:
                thiago Thiago Macieira
                Reporter:
                oryxdigital Andy Brice
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Gerrit Reviews

                  There are no open Gerrit changes