Writing to a file with QFile fails, without error code, when already opened in Excel

bizris

I try to write to an existing file with QFile, which works as expected. However, the problem is that if the file is open in Excel, writing to the file from my program fails.

I try to test the permissions with QFileInfo and have all read and write permissions on the file. The test

bool opened = file-> open (QIODevice :: WriteOnly) 

returns true.

The same problem does not occur when the file is opened with notepad++.

How can I check if the file is locked and can't be written to?

Pavel Strakhov

Excel locks its open files for exclusive use. You can't write to an open file, move or delete it. There is no way to bypass this lock.

See also: Write to locked file regardless of lock status

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Python: Writing into file fails without error - results in empty file

From Dev

python tests error when writing code for a already written test

From Dev

Exported excel file from datagridview shows error when opened VB

From Dev

Writing to excel file error

From Dev

Why do I get a Bad File Descriptor error when writing to opened File?

From Dev

Excel VBA Code to select opened Excel file

From Dev

"File already in use error" coming, but only when it is open in excel

From Dev

Set PowerPoint presentation when already opened (From Excel)

From Dev

Excel file generated by table2excel jQuery plugin throws error when opened

From Dev

File.ReadAllLines() fails to read from a file that is opened by Excel

From Dev

Not able to Close and delete already opened .xls file thro' java code

From Dev

Error when writing code php

From Dev

Python how to keep writing to a file without erasing what's already there

From Dev

Applescript: "File Already Open" when writing to new file

From Dev

Code only runs on Excel 2007 if file is opened from within Excel

From Dev

onOpen function fails to run when Google Sheets file is opened

From Dev

Tailing already opened file in Perl

From Dev

Writing an "Out of Memory" error to file, without memory?

From Dev

"File in use" error when writing to text file

From Dev

Iteration error writing file to excel with python

From Dev

Writing to Access table fails when an Excel workbook has an open connection to it

From Dev

Writing to Access table fails when an Excel workbook has an open connection to it

From Dev

i/o file writing code error

From Dev

Using vim to force edit a file when you opened without permissions

From Dev

Auto MsgBox when Excel file is opened and a condition is met

From Dev

Update excel file when opened if a new version is available

From Dev

Ansible file creation fails without any error

From Dev

Error when writing Pandas DataFrame to feather file

From Dev

NetworkX Key Error when writing GML file

Related Related

  1. 1

    Python: Writing into file fails without error - results in empty file

  2. 2

    python tests error when writing code for a already written test

  3. 3

    Exported excel file from datagridview shows error when opened VB

  4. 4

    Writing to excel file error

  5. 5

    Why do I get a Bad File Descriptor error when writing to opened File?

  6. 6

    Excel VBA Code to select opened Excel file

  7. 7

    "File already in use error" coming, but only when it is open in excel

  8. 8

    Set PowerPoint presentation when already opened (From Excel)

  9. 9

    Excel file generated by table2excel jQuery plugin throws error when opened

  10. 10

    File.ReadAllLines() fails to read from a file that is opened by Excel

  11. 11

    Not able to Close and delete already opened .xls file thro' java code

  12. 12

    Error when writing code php

  13. 13

    Python how to keep writing to a file without erasing what's already there

  14. 14

    Applescript: "File Already Open" when writing to new file

  15. 15

    Code only runs on Excel 2007 if file is opened from within Excel

  16. 16

    onOpen function fails to run when Google Sheets file is opened

  17. 17

    Tailing already opened file in Perl

  18. 18

    Writing an "Out of Memory" error to file, without memory?

  19. 19

    "File in use" error when writing to text file

  20. 20

    Iteration error writing file to excel with python

  21. 21

    Writing to Access table fails when an Excel workbook has an open connection to it

  22. 22

    Writing to Access table fails when an Excel workbook has an open connection to it

  23. 23

    i/o file writing code error

  24. 24

    Using vim to force edit a file when you opened without permissions

  25. 25

    Auto MsgBox when Excel file is opened and a condition is met

  26. 26

    Update excel file when opened if a new version is available

  27. 27

    Ansible file creation fails without any error

  28. 28

    Error when writing Pandas DataFrame to feather file

  29. 29

    NetworkX Key Error when writing GML file

HotTag

Archive