Prevent Deleting a currently Opened file Using Qt.
-
In Microsoft word, the user is not allowed to delete or rename a file if it is in used. I want to create a project that is similar to this. But how am I going to do that? I am new to QT. I don't know how to start. Can anyone help me with this?
I'm looking forward for your reply.
Thank you so much in advance. -
Hi and welcome to devnet,
AFAIK, that's the OS that forbids such operations on an opened file.
Or are you trying to do such things within your application ?
-
Hi thank you so much for your reply.
Yes, I am trying to create that within my application.
I made a project that could save and edit a text file. Like a notepad. What I want is if that file is opened. I want a messagebox or something that will pop up when the user tries to delete/rename the certain file. -
How is the user supposed to delete the file ?
-
Hmmmm.. Let's say for example you have a saved file called "sample.txt" in the documents. Then you open it using the application you created in QT. Then the user will try to delete that file in the documents. I want a message to pop up... something like "action cannot be completed because the file is open in another application." something like this.
-
You need some kind of file lock, and pray that deleting application respects your lock.
-
You need some kind of file lock, and pray that deleting application respects your lock.
You need some kind of file lock, and pray that deleting application respects your lock.
Which on *nix is (almost) never the case.
-
One alternative that comes to mind is to work on a "copy" of the file and next time you save it you can tell your user that the file is gone.