如何知道哪个应用程序/程序正在使用C#中的文件 [英] How to know which application/program is using a file in C#

查看:80
本文介绍了如何知道哪个应用程序/程序正在使用C#中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.
我的软件使用了一个.inf文件,当我尝试访问该文件时,它说文件正在被另一个进程使用".我需要您的帮助来找出正在使用该.inf文件的进程的名称.请帮助我.我希望C#中的代码能够找出答案,因为我的应用程序在c#中.
谢谢与问候
Dinesh

Hi all.
There is a .inf file used by my software, which when i try to access says "File is in use by another process". I need your help in finding out the name of the process which is using that .inf file. Please help me.I want the code in C# to find this out , as my application is in c#.
Thanks & regards
Dinesh

推荐答案

您不能-您只能说它正在使用中.最可能的罪魁祸首是您自己的应用程序!

检查打开文件的所有位置是否已完全关闭,并放置访问对象(流等),如果没有,则它们可以将文件保持为正在使用"状态,直到启动垃圾回收器并为之工作为止.您.
You can''t - you can just tell it is in use. The most likely culprit is your own application!

Check everywhere you open the file that you have fully closed and disposed the accessing objects - streams and so forth - if you do not, then they can hold the file as "in use" until the garbage collector is kicked in and does the job for you.


这篇关于如何知道哪个应用程序/程序正在使用C#中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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