How to tell who is accessing file

T

tshad

In XP, I am trying to determine who has a file open that is preventing me
from renaming or deleting the file.

I thought you could:

Right click my computer, choose manage, expand shared folders, and between
sessions and open files you can id the user.

I have the file open in excel and both sessions and open files have nothing
in them, but when I try to delete or rename the file, I get the error:

****************************************************************
Cannot rename zip-codes-database-standard: The file is in use by the
following program:

Microsoft Office Excel

You must close the file before proceeding.

****************************************************************

Why is this file not in the sessions or open files in the Computer
Management program?

Thanks,

Tom
 
J

John

tshad said:
Right click my computer, choose manage, expand shared folders, and between
sessions and open files you can id the user.

Sure if the file is in a shared folder and you open it from another
networked PC
I have the file open in excel and both sessions and open files have
nothing in them,

It shows nothing if the file is the same PC where the shared folder is.
but when I try to delete or rename the file, I get the error:

Because the file is in use. Close it then rename the file.
Why is this file not in the sessions or open files in the Computer
Management program?

see above.
 
T

tshad

John said:
Sure if the file is in a shared folder and you open it from another
networked PC


It shows nothing if the file is the same PC where the shared folder is.


Because the file is in use. Close it then rename the file.


see above.

Is there a way to see what is holding the file? The file is not set to
readonly from the OS?

In my code, I can do:

FileInfo testFile = new FileInfo(fileName);
if (testFile.IsReadOnly)

This shows the file as read only, even though the OS doesn't show it that
way. I also can't tell what is holding it. Once I close excel (or the
window showing the file), I can now access it.

Thanks,

Tom
 
T

tshad

What started this was I was testing some code and copied a 10 MB from folder
A to Folder B on the same drive.

When I went back to Folder A, I could rename or delete this file.

When I went to Folder B, I would get the following message if I tried to
delete or rename the file:

****************************************************************************
Cannot delete zip-codes-database-standard: It is being used by another
person or program.

Close any programs that might be using the file and try again.

****************************************************************************

After about 5 minutes or so, I could now delete the file or rename it.

If I tried to delete it, it would take about 5 seconds to give me the
message.

If I tried to rename it, I would get the message immediatly.

What is causing this?

Thanks,

Tom
 
T

Twayne

tshad said:
Is there a way to see what is holding the file? The file is not set
to readonly from the OS?

In my code, I can do:

FileInfo testFile = new FileInfo(fileName);
if (testFile.IsReadOnly)

This shows the file as read only, even though the OS doesn't show it
that way. I also can't tell what is holding it. Once I close excel
(or the window showing the file), I can now access it.

Thanks,

Tom

Not unusual. There is no guarantee a file that was opened by any
application will be returned/closed/memory released until the
application closes. Closing Excel should usually clear the "in use'
situation, but even then it could still be seen as in use sometimes,
depending on how write-behind buffers, etc., are managed and whether all
the data has been written to disk yet. It gets frustrating sometimes, I
agree.

HTH,

Twayne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top