Skip to main content
Topic: File Permission Problem (Read 4454 times) previous topic - next topic

File Permission Problem

OS: WinXP (Home Edition)
nwc2.exe ver 2.0.4.0
  • create a folder
  • open MOZART.NWC
  • export it to the New Folder
  • using Explorer, try to delete the New Folder
The exported file is deleted, but WinXP reports that the folder is in use.

Back in NWC2:
  • Export MOZART.NWC to some other folder (Old Folder)
  • using Explorer, try to delete the New Folder
The New Folder can now be deleted.
You can also exit NWC2 and delete the folder.

Win98 does not exhibit this behavior.
Registered user since 1996

Re: File Permission Problem

Reply #1
The same problem on Import:
  • create a New Folder
  • put a(n) nwctxt file into the New Folder
  • Import the nwctxt file using File->Import
  • using Explorer, try to delete the New Folder
The nwctxt file is deleted, but WinXP reports that the folder is in use.

I'm trying to create scripts to automate the process of generating and analyzing MIDI and/or nwctxt files.
Unfortunately, this bug prevents the scripts from cleaning up after themselves.
Registered user since 1996

Re: File Permission Problem

Reply #2
G'day Rick,
I've found similar things with NT based windows systems in lots of environments.  It seems to have something to do with windows not releasing file handles in a timely fashion...

And you are correct, non NT versions of windows (3.1, '95 '98) do not exhibit this.
I plays 'Bones, crumpets, coronets, floosgals, youfonymums 'n tubies.

 

Re: File Permission Problem

Reply #3
It seems to have something to do with windows not releasing file handles in a timely fashion...
That's not the problem here. You can wait an hour after import/export and still not be able to delete the folder. If you do an other import/export with a different folder, you can delete the first folder immediately.

More likely, NT added an extended function call and NWC2 is still using the legacy function.

It would help if someone could confirm that this is a problem on their computer. It could be that my version of XP is wonky.

Edit: Various flavors of Windows have varying permission rules.
Registered user since 1996

Re: File Permission Problem

Reply #4
G'day Rick,
That's not the problem here. You can wait an hour after import/export and still not be able to delete the folder. If you do an other import/export with a different folder, you can delete the first folder immediately.

More likely, NT added an extended function call and NWC2 is still using the legacy function.

It would help if someone could confirm that this is a problem on their computer. It could be that my version of XP is wonky.

I manage a lot of networks...  I see this problem a bit when managing files on the server from a workstation.  You know, moving stuff around, deleting and copying - removing folders etc.  It is not uncommon to be unable to delete an empty folder because the workstation hasn't released "something".  Sometimes doing other things and coming back will release whatever is being held open, sometimes not.  It seems to be unpredictable and on several occasions I've even had to resort to rebooting the workstation to get the empty folder deleted.

Given this is using Windows tools to perform the required file management I don't think the finger can be pointed at NWC possibly using a legacy function - it definitely is not limited to NWC.
I plays 'Bones, crumpets, coronets, floosgals, youfonymums 'n tubies.

Re: File Permission Problem

Reply #5
Hi Rick.

I tried with win2000 and there is the same problem but with a little difference: I get the message "the folder is in use" and the file is NOT deleted.

Re: File Permission Problem

Reply #6
I see this problem with several different programs, and it happens for me on both WinXP Pro and Vista Ultimate.  Usually (depending on the program I'm using), if I close everything in a particular folder and then explicitly move away from that folder to a different folder, I can usually delete files/folders.  But not always.  Usually exiting the program frees everything up, but on rare occasions, I've had to reboot the computer.  I figured it was a Windows thing, since I've seen it in several different programs.
John

Re: File Permission Problem

Reply #7
Thanks Maurizio.

John & Lawrie,
It is hardly news to me that Windows locks files and folders for no apparent reason.

What I need to know is how various flavors of Windows handle the situations outlined in the my original post and in reply #1.

M$ describes a problem here:
Quote from: http://technet.microsoft.com/en-us/library/bb490990.aspx
Deleting the current directory
You cannot use rmdir to delete the current directory. You must first change to a different directory (not a subdirectory of the current directory) and then use rmdir with a path. If you attempt to delete the current directory, the following message appears:
    The process cannot access the file because it is being used by another process.
What is unsaid is that, under certain versions, you cannot use rmdir to delete a directory if it is the current directory of any running task.

It appears to me that when NWC2 puts up a File dialog and the user's selection is successful, the File dialog dll changes NWC2's current directory to that of the file and locks the folder. Invoking a User Tool also seems to lock the folder of the tool. This lock persists until NWC2 closes or its current directory is changed.  Opening a file from History or Explorer does not seem to lock the folder of the opened file.

If this is indeed the case, it would be most helpful if NWC2 would promptly change back to its original home directory.
I would think that it is good programming practice not to lock files or folders longer than necessary.

Here's a little script I use to investigate the problem.
Quote from: chdir.vbs
Option Explicit
' chdir %temp%\a, create if needed
Dim wso: Set wso = CreateObject("WScript.Shell")
Dim fso: Set fso = CreateObject("Scripting.FileSystemObject")

wso.CurrentDirectory = fso.GetSpecialFolder(2) ' cd %temp%
If Not fso.FolderExists("a") Then fso.CreateFolder("a") ' mkdir a
wso.CurrentDirectory = ".\a" ' cd %temp%\a
Dim s: s = wso.CurrentDirectory & vbLf

wso.PopUp s & "cannot be removed",, wso.CurrentDirectory, 16
wso.CurrentDirectory = fso.GetSpecialFolder(2) ' cd %temp%
wso.PopUp s & "can be removed",, wso.CurrentDirectory, 48
Registered user since 1996

Re: File Permission Problem

Reply #8
I suspect that you have identified the exact cause. The File Open/Save dialogs have a habit of different behavior across Windows versions. Windows 7 seems to do something different yet again. We will keep this area in mind for improvements.

Note that NWC does not lock files on its own, even while you are editing them.