我在尝试使用.mkv文件(vlc.exe,mpc-hc.exe等)进程的名称如何找出正在使用哪个进程的文件
我已经设法发现它是否在使用中,但我想知道至关重要的进程正在使用该文件。
我试过了这个帖子How do I find out which process is locking a file using .NET?的建议,但只是插入文件的路径并运行它似乎没有工作,它没有显示任何进程(我可以运行代码没有错误)。
public static bool IsFileinUse(FileInfo file)
{
FileStream stream = null;
try
{
stream = file.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None);
}
catch (IOException)
{
//the file is unavailable because it is:
//still being written to
//or being processed by another thread
//or does not exist (has already been processed)
return true;
}
finally
{
if (stream != null)
stream.Close();
}
return false;
}
这可以帮助你在正确的方向走http://stackoverflow.com/questions/958123/powershell-script-to-check-an-application-这就是锁定文件 –
http://stackoverflow.com/questions/317071/how-do-i-find-out-which-process-is-locking-a-file-using-net –
http:// stackoverflow.com/questions/860656/using-c-how-does-one-figure-out-what-process-locked-a-file –