2

Consider a network folder:

\\desiis\c$\Company\B2b\Monitor

On that machine, any process that tries to delete the directory Monitor receives an error because a user on the LAN has that directory open (likely with Windows Explorer).

Can I detect, via C# and .NET framework, if any user (and which user) has a particular directory open/in use?

0

2 Answers 2

2

I'm not sure if you can obtain the particular user in the directory but the DirectoryInfo class in C# .NET would probably be the best way to go.

http://msdn.microsoft.com/en-us/library/system.io.directoryinfo_members.aspx

Review the API at this link and you'll notice there is a method to get the information about WHEN the directory was last accessed but not by who. Also you can catch any exception when trying to delete a directory as it being unavailable (an exception will be thrown as you are probably well aware).

Also note that exception catching is costly and you should evaluate any slowdowns in your process by doing this.

Sign up to request clarification or add additional context in comments.

1 Comment

I need API kernel32.dll (any method, which??) about it (for knows the user who uses the directory) ?? thanks !!!
2

No, there is no possibility I know.

It seems you'll have to catch the occuring Exception as a workaround.

1 Comment

it's a pity :'( perhaps, any guru of Microsoft will have a solution... I pray for it...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.