Breaking open file connections in .net


Does anyone know of a way to break open file connections remotely? I have used the NetFileEnum API in visual basic 6 but I am re-writing my application in .NET(C#) and was hoping .NET had a better way of handling this? Also I will be executing the app on a Windows 2003 server and I dont think it will support this API call.

Thanks in advance
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

There are a couple of command line tools that can do it but they need to be executed on the server.  So, you would need to work out how to remotely execute Command Line procedures.  That could be a whole other problem though..?

Anyway, look into the following:

If the file is locked on the server then it first needs to be unlocked / diconnected.  This is done by:

OPENFILES /query - This will return a list of open files and their ID's


OPENFILES /Disconnect /ID 2244665 - This will unlock file '2244665'


NET FILE 2244665 /Close

Again, executing these commands remotely could be a problem but if you can work that out then you're away.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.