【发布时间】:2009-09-11 12:37:49
【问题描述】:
我正在使用 DotNetZip 库将文件压缩到一个文件夹中。为了识别当前由其他进程打开的文件,我使用了来自 SysInternals.com 的“handle.exe”。我通过使用参数调用它并解析输出来做到这一点。
using (Process handleProcess = new Process())
{
// -- Set up the parameters and call the process.
handleProcess.StartInfo.FileName = "handle.exe";
handleProcess.StartInfo.UseShellExecute = false;
handleProcess.StartInfo.RedirectStandardOutput = true;
handleProcess.StartInfo.Arguments = "-u " + fileName;
handleProcess.Start();
...
这很有效,但有一种杂乱无章的感觉。任何人都可以在托管代码中提出更好的方法吗?
【问题讨论】: