-Cannot delete folder after open configuration files

The behaviour described in the bug report is either by design, or would be far too complex/time-consuming to be changed

Moderators: Hacker, petermad, Stefan2, white

User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

This is NOT a bug: Windows refuses to delete a directory which is the current directory in ANY open program. So when you launch a program from a directory and that program doesn't change the current directory, you will not be able to delete that directory until you close that program.
Author of Total Commander
https://www.ghisler.com
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by *MarcinW »

Let's make a small summary.

1) This is of course not a bug, that Windows doesn't allow to delete a directory that is being used by some application (Notepad in this case).

2) TC could be improved in an easy way - when launching Notepad with INI files, TC should set working directory of this Notepad to the directory of these INI files, not to the directory that the user can see in the active TC panel when Configuration -> Change Settings Files Directly command was used. In this way, Notepad will not block user actions by keeping handle to the directory that is shown in the active TC panel. This may be considered as a small TC bug, which can be fixed in 1 minute.

Regards
User avatar
petermad
Power Member
Power Member
Posts: 16032
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

I agree that it would be user friendly if TC did set the working directory to %COMMANDER_INI%\.. when launching cm_ConfigChangeIniFiles
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
JFierce7
Senior Member
Senior Member
Posts: 214
Joined: 2005-07-17, 10:47 UTC

Post by *JFierce7 »

ghisler(Author) wrote:This is NOT a bug
I still disagree. The bug is, that notepad is inproperly called.

BTW, if you happen to execute the "edit configuration files" menu item while an USB drive directory is current, that drive cannot be safely removed as long as the files are kept open. There's no reason to not fix such behaviour. Also, for the user it is not really obvious what he or she has to do to remove the device.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

No, it's not improperly called! Many programs use the current directory when searching for files, so it's beneficial to call them with the current directory.
Author of Total Commander
https://www.ghisler.com
Sob
Power Member
Power Member
Posts: 945
Joined: 2005-01-19, 17:33 UTC

Post by *Sob »

Not that I care about this one, but you realize this discussion is *only* about one specific case when you click Configuration->Change Settings Files Directly, right? So there's no unknown program which might need something in *current* directory. There's only predictable notepad.exe and the only directory it needs, is the one where TC's ini files are located.
JFierce7
Senior Member
Senior Member
Posts: 214
Joined: 2005-07-17, 10:47 UTC

Post by *JFierce7 »

Sob wrote:but you realize this discussion is *only* about one specific case when you click Configuration->Change Settings Files Directly, right?
Yes, thanks, Sob! And I don't see where the behaviour in this specific case would be any beneficial. However, I see the disadvantages.
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by *MarcinW »

I agree with ghisler(Author) that TC should use the current directory when launching any programs in normal cases.

The idea of TC is that the user works with files and folders in the TC panels. So when he goes to - let's say - C:\Documents and Settings\X\My Documents\, he may launch Notepad/Word/etc. with this folder as the current directory and benefit from easy access to other files inside this directory in the launched application.

In the specific case of editing INI files, current TC behavior invalidates this idea, because the user loses full control of folders shown in panels (he can't delete the folder that was shown in the active panel at the moment of using the Configuration -> Change Settings Files Directly command).


There are two possibilities:

1) Current TC behavior - when loading INI file(s) to the Notepad(s), TC locks the folder shown in the active panel.
Advantage: The user can easily open other files from that folder in Notepad by using Notepad's File -> Open command - but is this really needed? It's much easier for the TC user to find the required file in the active TC panel and press F4.
Disadvantage: The user can't delete that folder.

2) When loading INI file(s) to the Notepad(s), TC locks the folder containing these INI files, not the folder in the active panel.
Advantage: The user retains full control over the folder displayed in the active panel.
Disadvantage: Is there any? The user has exactly what he wants - INI file(s) loaded into Notepad(s). Most probably he will not need to open any other files in this/these Notepad(s) instance(s).

So, in my personal opinion, this second case would be better in this specific case of editing INI files.

Regards
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Unfortunately there are a lot of similar problems with any folder. E.g. it may be CMD.exe, it may be some program that you start via file context menu, it may be some other program like text editor etc. And simplest way to delete such locked folder is to close all its open handles (by closing programs or by changing dirs in them if they allow it or by closing handles forcedly).

In case of such special function TC always opens specific files (configuration files) so personally I agree that TC should set proper working directory (one containing these files). It won't solve other problems with locked dirs though.

However this may be easilly solved with custom user command opening configuration files, e.g.:

Code: Select all

Command: cmd.exe
Parameters: /c "start "" "notepad.exe" %%COMMANDER_INI%% & start "" "notepad.exe" %%COMMANDER_INI%%\..\wcx_ftp.ini"
Start path: C:\Windows (this is a key setting that solves this problem)
Minimized: yes
Such command may be made as a buttonbar button, or as a user-command (in such case it may be added to main menu, even instead of standard command opening cfg files; also hotkey may be assigned to it). Also your favorite text editor may be called instead of unhandy Notepad.
User avatar
petermad
Power Member
Power Member
Posts: 16032
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

Command: cmd.exe
Parameters: /c "start "" "notepad.exe" %%COMMANDER_INI%% & start "" "notepad.exe" %%COMMANDER_INI%%\..\wcx_ftp.ini"
Start path: C:\Windows (this is a key setting that solves this problem)
Minimized: yes
The only problem with this is if the user are using another filename for wcx_ftp.ini

We could use an environment variable for wcx_ftp.ini too.
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

It is just an example for default names of configuration files, it is easy to edit it. However I agree that there is no simple way to know real wcx_ftp.ini location if user has altered it.
JFierce7
Senior Member
Senior Member
Posts: 214
Joined: 2005-07-17, 10:47 UTC

Post by *JFierce7 »

Thanks, MarcinW, for this summary.
MarcinW wrote:1) Current TC behavior - when loading INI file(s) to the Notepad(s), TC locks the folder shown in the active panel.
Advantage: The user can easily open other files from that folder in Notepad by using Notepad's File -> Open command - but is this really needed? It's much easier for the TC user to find the required file in the active TC panel and press F4.
Disadvantage: The user can't delete that folder.
Furthermore, the user cannot safely remove an external (USB) drive, if the active folder at the moment of opening config files had been opened accidentally from that drive.

What really makes this a problem to the user, is that, although there's a message shown about the folder or drive being locked, those config files are not related to the folder or drive, so it's not obvious which process is responsible.
JFierce7
Senior Member
Senior Member
Posts: 214
Joined: 2005-07-17, 10:47 UTC

Post by *JFierce7 »

What is the particular reason or advantage of current behaviour that this issue will not be resolved?
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6975
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Post by *Horst.Epp »

JFierce7 wrote:What is the particular reason or advantage of current behaviour that this issue will not be resolved?
May be because of the side-effects discussed
Or because most users never have such a problem.
I'm working since Windows 3.1 with TC and never had it for example.
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by *MarcinW »

Horst.Epp wrote:most users never have such a problem.
There is probably about 300 000 users of TC, so if 1% of them has this problem, it gives 3 thousands of users...

BTW, according to side effects, the current discussion shows, that there are rather no practical side effects of such potential change.

And this is true, that we are currently unable to dismount USB drive safely, if it has been shown in the active panel during launching the "Change Settings Files Directly" command.

Regards
Post Reply