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

QSaveFile unable to open UNC path to write on Windows

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 6.1.1, 6.2.0 Alpha
    • 5.11.1
    • Core: I/O
    • tested on Windows 7 and Windows 10
    • Windows
    • ec9e85656339dbc9e6918a1369c981cece7bc97d (qt/qtbase/dev) 9d0be7b1a920cd9d7ae949bc3dc14774a439b3d0 (qt/qtbase/6.0) ad12c3c40b07079d875f48027eef0786acef7de0 (qt/qtbase/6.1)

    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

        Issue Links

          Activity

            People

              heimrich Karsten Heimrich
              oryxdigital Andy Brice
              Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: