Stubborn busy file, can't delete, can't write to...

I have an HTML file stored on our server that is written to via AS by one station, read by another script on another station, and viewed by a group of about 10 people on a hodge podge of OS’s both PC and Mac.

Occasionally, and much more frequently these days, the script that tries to write to it fails due to the fact that the file is busy. This is a mission critical script and failure is not an option. This file simply refuses to be deleted, written to, moved, replaced by a copy, or looked at wrong . The only thing that does work to remove the stupid file is to rename the folder that houses it, make a new folder with the old name, then make a copy of the file there. Unfortunately I also store about a hundred thousand other things in that folder AND the path to the folder itself is hardwired into about 20 active scripts, so jumping through this hoop is a time consuming process and making any change to lighten the load will be painful.

My question(s)
Does anyone know what may be hogging this file? I’ve tried deleting it from every station that could possibly be reading or writing to it. All fail with the so very helpful file error has occurred message.


Does anyone know of a command that will nuke the file without error? I’ve tried about 10 different commands to delete this file and all return a file busy error.

Thanks in advance!

I know that this is a basic question but is the file closed faithfully after it’s been opened for read/write access?

Is the server protecting the file with permissions?

Thanks Rob,

I can’t check my code right now but I’m pretty sure I’m not opening the file up for access, however I will check tomorrow to verify. I believe I am just setting the eof to 0 and writing over it. Plus, when this has happened in the past I’ve tried the close access command on the station that does the writing but it tells me the file isn’t open. Yet deletion attempts yield the same file busy messages. So, this tells me that the station that is writing the file does not have it open.

I was kind of wondering if someone in the group of people that view the page could have it locked up, either due to a crash, or some other rare reason.

If they are simply viewing it in a browser, I doubt it. Otherwise, the Internet would be a helluva mess due to the frequency of Windows crashes that occur on a daily basis. :twisted:

I wonder if the server software keeps the file flagged as busy. Is this problem limited to this single file?

– Rob

It is a mess but that is beside the point. 8^) I was thinking more along the lines of some strange local area network file permission bug.

The problem is limited to this file. I have scores of other files written to and read from on the same volume with no problem. None of them are HTML files though, only text.

In the past, I have had our LAN admin just nuke the file for me. They had no answer as to why it was busy.

I checked my code and I do not use open for access. I merely set the eof to 0 and write to the file. I would think I would still get the same file busy message if I tried to open for access anyway?


I’d guess that ‘set EOF to 0’ might open the file for access because I’m under the impression that a file must be open before it can be written to. I would throw a close access into a try block just to see if it helps. Something like this:

	-- file writing code
		close access file_
	end try
on error
		close access file_
	end try
end try

Note: You might need to nuke the file that’s there now in order for this to have any chance of helping the situation.

– Rob

Thanks Rob, I’ll give that a try. It may be some time before it happens again as the frequency usually ranges from 1 to 2 weeks between occurrences.

Thanks again!