Results 1 to 2 of 2

Thread: QFile::copy says “can't open source file for input”?

  1. #1
    Join Date
    Jul 2010
    Posts
    30
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default QFile::copy says “can't open source file for input”?

    I'm going to copy one file using QFile::copy function but this function always returns false and errorString says :

    "Cannot open D:/tmp/buf34.txt for input"
    I tried to run this program with administrator privilege but nothing changed. My code is really simple :

    Qt Code:
    1. QString source = url.toLocalFile();
    2. QString destination = _dir.absolutePath()
    3. + QString("/%1").arg(QFileInfo(source).fileName());
    4. qDebug()<<"Cp from :" << source << " to : "<< destination;
    5. QFile file(source);
    6. qDebug()<<file.copy(destination);
    7. qDebug()<<file.errorString();
    To copy to clipboard, switch view to plain text mode 
    I have QListView occupied with a QFileSystemModel. I try to drag one file from this ListView to a QLabel. For the QLabel a destination path is set. In drop event I try to copy file.
    Impossible = I'mpossible

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: シーバイ クãƒ*エ バッグ=http://goo.gl/dSG3C

    Assuming the file exists and you have read permissions for it, check that it is not opened somewhere else in either your program or another.
    Window's file system uses a allow-open-only-once restriction.

    Cheers,
    _

Similar Threads

  1. Replies: 0
    Last Post: 26th November 2012, 14:18
  2. QFile::copy copies only 3kb
    By camol in forum Qt Programming
    Replies: 36
    Last Post: 20th April 2011, 20:52
  3. Replies: 1
    Last Post: 10th March 2011, 15:40
  4. QFile open file on a shared drive
    By gaddlord in forum Qt Programming
    Replies: 0
    Last Post: 25th August 2010, 00:19
  5. QFile::writeBlock: File not open
    By safknw in forum Qt Tools
    Replies: 1
    Last Post: 16th September 2006, 14:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.