我有那里的人都连接到文件共享上的情况,它的阻止我从覆盖文件。我试图写一个方法,将看看如果我提供了一个文件路径目前陷入了这种方式,并关闭该资源的网络会话。
I have a situation where people are connected to files on a share and it's blocking me from overwriting the file. I'm trying to write a method that will look to see if a filePath that I provide is currently locked in this way and close the network session of this resource.
我看了看ADSI WinNT提供,但Resources.Remove成员未实现。然后我看着Win32_ServerSession,虽然我可以使用删除成员,它杀死所有的资源给定用户。我需要弄清楚如何更具体。
I looked at the ADSI Winnt provider but the Resources.Remove member isn't implemented. Then I looked at Win32_ServerSession and while I am able to use Delete member, it kills all of the resources for a given user. I need to figure out how to be more specific.
我已经走GetRelationsShips和性能,但我只是在此刻难住了。
I've been walking GetRelationsShips and Properties but I'm just stumped at the moment.
推荐答案这将是很难考虑这样做的所有后果,因为你不一定能预测结果,目前已锁定文件的应用程序的行为。
It would be difficult to consider all the ramifications of doing this because you can't necessarily predict the resulting behavior of the application that currently has the file locked.
有一些其他的方式来做到这一点?例如你有没有覆盖该文件向右走,或者你可以有不断地尝试覆盖该文件每隔几分钟,直到成功?
Is there some other way to do this? For example do you have to overwrite the file right away, or can you have some external process that continually tries to overwrite the file every few minutes until it succeeds?
更多推荐
关闭使用C#打开文件
发布评论