通过强制C#关闭已打开的文件 [英] Forcing closed an open file by C#

查看:1852
本文介绍了通过强制C#关闭已打开的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了一个类似的问题这里但它是封闭的/一个答案接受的不这样做。

I found a similar question here but it was closed/accepted with an answer of "don't do that".

我在我不在乎会发生什么其他的应用程序的情况下,我想带一个文件可能被其他人锁定(粗鲁如果需要的话),并有我与它的方式。我可能需要移动,重命名或删除该文件。

I'm in a situation where I don't care what happens to the other applications, I want to take a file that may be locked by others (rudely if needed) and have my way with it. I may need to move, rename, or delete this file.

基本上我需要处理在由一个应用程序创建一个目录中的文件没有清理它的锁。我知道,当我的调用程序完成处理,但我需要当我运行杀锁。此外,似乎我与本地杀毒软件扫描远程共享所在的服务器读取发生冲突。

Basically I need to process files in a directory that is created by an app that doesn't clean up it's locks. I know the app is done processing when mine calls, but I need to kill the locks when I run. In addition it seems I'm conflicting with reads from local AV software scanning the remote share where the server is.

这一切都增加了一个不可避免的强制关闭的情况所以我可以做什么,我需要。是否有人在做什么想法?

All this adds up to an unresolvable "force close" situation so I can do what I need. Does anyone have an idea on what to do?

推荐答案

首先,你可以使用这个帖子,以验证它是一个的锁定狡猾的应用其中:

First you can use this post to verify that it's the dodgy app that's locking them:

http://stackoverflow.com/questions/317071/how-do-i-find-out-which-process-is-locking-a-file-using-net

那么这篇文章概括的方式来关闭它们:

Then this post outlines a way to close them:

http://social.msdn.microsoft.com/Forums/en -US / csharplanguage /线程/ 04a1e899-2a38-4d95-8ed5-6d53344e4d76

这篇关于通过强制C#关闭已打开的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆