Hi, everyone.
I create a file,and then open it with other apps or process(such as Firefox,IE),and when create the file again, I should determine isopend or not, and alert the user to close first.
Is there some way can be achieved?
thanks.
Is there some way to determine whether the file is in use? Topic is solved
-
- Experienced Solver
- Posts: 86
- Joined: Wed Apr 18, 2007 6:10 am
- Location: Shanghai China
if that another app uses file locks than yes. You may query existing locks and act appropriately.
However most often application would open file, read it, close it immediately, then proceed to display its contents. That way, file is long closed and not used at all even if its content is still on screen.
However most often application would open file, read it, close it immediately, then proceed to display its contents. That way, file is long closed and not used at all even if its content is still on screen.
-
- Experienced Solver
- Posts: 86
- Joined: Wed Apr 18, 2007 6:10 am
- Location: Shanghai China
- evstevemd
- Part Of The Furniture
- Posts: 2293
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
- Contact:
There is function called isopen()
I dont remember where but it is in file. Just search wxDocs for that word.
I dont remember where but it is in file. Just search wxDocs for that word.
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 19.04/Windows 10 Pro/MacOS 10.13 - GCC/MinGW/Clang, CodeLite IDE]
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 19.04/Windows 10 Pro/MacOS 10.13 - GCC/MinGW/Clang, CodeLite IDE]
-
- Experienced Solver
- Posts: 86
- Joined: Wed Apr 18, 2007 6:10 am
- Location: Shanghai China
Hi,
I use this code to test if the is using.
but the first time,this is ok,but the following it always return false(IsOpend() return true);
At last, I have to remove the file for test.
I use this code to test if the
Code: Select all
fileToWrite
Code: Select all
wxFile file(fileToWrite);
if (file.IsOpened())
{
wxMessageBox( _("The files are used. Please close the browser before proceeding."));
return false;
}
At last, I have to remove the file for test.
Code: Select all
if (wxRemoveFile(fileToWrite)==false)
{
wxMessageBox( _("The files are used. Please close the browser before proceeding."));
return false;
}