Results 1 to 2 of 2

Thread: Unable to open a file which was previously opened and close using ifstream in ios

  1. #1
    Join Date
    Feb 2015
    Posts
    185
    Thanks
    5
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Unable to open a file which was previously opened and close using ifstream in ios

    There is a file which I opened and read the contents and closed.

    When I visit again to try to read the file using another instance, is_open() is failing.
    Below is the code which does it.
    Qt Code:
    1. QString Decrypt::decryptFile(QString sourceFile,QChar keystring)
    2. {
    3. _decrptedResStr.clear();
    4. string srcFile=sourceFile.toUtf8().constData();
    5. ifstream ffin;
    6.  
    7. ffin.open(srcFile.c_str(),ios_base::in|ios_base::binary);
    8.  
    9. char keyToEncryption= keystring.toLatin1();
    10. if(ffin.is_open())
    11. {
    12. char ch;
    13. while(!(ffin.read(&ch,1).eof()))
    14. {
    15. ch ^= keyToEncryption;
    16. _decrptedResStr.append(ch);
    17. }
    18. }
    19. ffin.close();
    20. return _decrptedResStr;
    21. }
    To copy to clipboard, switch view to plain text mode 
    Kindly let me know how to read the file again.
    Last edited by anda_skoa; 2nd March 2015 at 13:15. Reason: missing [code] tags

  2. #2
    Join Date
    Feb 2015
    Posts
    185
    Thanks
    5
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: Unable to open a file which was previously opened and close using ifstream in ios

    Got the issue resolved.
    Issue was with the ini file. Haven't added the group name in the .ini file

Similar Threads

  1. Replies: 0
    Last Post: 4th September 2013, 10:05
  2. Replies: 0
    Last Post: 31st May 2013, 15:40
  3. How can I save the windows I have previously opened ?
    By Marwa Shams in forum Qt Programming
    Replies: 4
    Last Post: 25th September 2011, 20:28
  4. err:"Unable to restore previously selected frame"
    By BalaQT in forum Qt Programming
    Replies: 1
    Last Post: 19th September 2009, 13:18
  5. Replies: 5
    Last Post: 19th April 2009, 14:24

Tags for this Thread

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.