Check file is open or not
-
@koahnig i use this but its notworking.
give me some another solution.@Gaurav-Badgujar
try#include<QFile> #include<QDebug> QFile file(pathToFile); if(!file.open(QIODevice::readonly){ qDebug() << "File not open" << file.error(); }else{ qDebug() << "File is open"; }
that should tell you why Qfile could not open the file.
-
@koahnig i use this but its notworking.
give me some another solution.@Gaurav-Badgujar What is not working? QFile is the most simple way in Qt to open a file. Just saying "its not working" is not very helpful.
-
@Gaurav-Badgujar
can u post the code which u have tried.what is the return value u are getting?.
Thanks,
-
@Gaurav-Badgujar
try#include<QFile> #include<QDebug> QFile file(pathToFile); if(!file.open(QIODevice::readonly){ qDebug() << "File not open" << file.error(); }else{ qDebug() << "File is open"; }
that should tell you why Qfile could not open the file.
@J.Hilk its not working with this.
i opened excel file in ms-excel and i want to check excel file is open or not.
-
u may look into the below link
https://forum.qt.io/topic/51169/how-to-check-whether-file-already-open-or-not-in-qt
i hope this is what ur topic says.
Thanks,
-
u may look into the below link
https://forum.qt.io/topic/51169/how-to-check-whether-file-already-open-or-not-in-qt
i hope this is what ur topic says.
Thanks,
@Pradeep-Kumar yup .. but i want solution.
-
@J.Hilk its not working with this.
i opened excel file in ms-excel and i want to check excel file is open or not.
@Gaurav-Badgujar said in Check file is open or not:
i opened excel file in ms-excel and i want to check excel file is open or not.
What? You open an Excel file in Excel and then you want to check whether Excel opened the file?
Do you open this Excel file manually or from your Qt app? Why do you want to check this? -
@Gaurav-Badgujar said in Check file is open or not:
i opened excel file in ms-excel and i want to check excel file is open or not.
What? You open an Excel file in Excel and then you want to check whether Excel opened the file?
Do you open this Excel file manually or from your Qt app? Why do you want to check this?@jsulm yes open manually and want to check for requirement.
-
@jsulm yes open manually and want to check for requirement.
@Gaurav-Badgujar Do you want to check this in your Qt app?
-
@Gaurav-Badgujar Do you want to check this in your Qt app?
@jsulm yes
-
@jsulm yes
There is no Qt way of doing this.
Its pr. operating system and you will need to use native API to do it.for windows
https://stackoverflow.com/questions/1951791/how-to-check-if-a-file-is-already-open-by-another-process-in-c -
You can check if a specific Excel file is open using ActiveQt
get all WorkBooks, iterate over them and check if the name of the workbook you touch corresponds to the one you want.
If that is the case, your excel file is already open. -
@mrjj
Yes, that is possible, but other files can be open already and the one we want to check is not necessarily the active one.Eddy