【发布时间】:2016-03-28 20:23:36
【问题描述】:
我想在我的 .NET C# 应用程序中使用 IFileOperation。
我找到了这篇文章http://blogs.msdn.com/b/msdnmagazine/archive/2007/12/12/6738569.aspx(源代码在这里http://download.microsoft.com/download/f/2/7/f279e71e-efb0-4155-873d-5554a0608523/NetMatters2007_12.exe)。 到目前为止它运行良好,但我想获取所有操作的状态和错误信息。
有一行代码:
if (_callbackSink != null) _sinkCookie = _fileOperation.Advise(_callbackSink);
这应该允许我访问这些信息,但我不知道如何使用它。
这就是我的称呼,我想在 fileOp.PerformOperations(); 之后获得一些带有结果的操作列表;类似的东西:
File/Folder name | Action | Result
d:\test\ | Copy | OK
d:\test\a.jpg | Copy | OK
d:\test\b.jpg | Copy | CALCELED
using (FileOperation fileOp = new FileOperation(new FileOperationProgressSink(), this)) {
fileOp.CopyItem(source, destination, name);
fileOp.PerformOperations();
}
我知道我可以在 FileOperationProgressSink.PostCopyItem 中获取这些信息,但我需要它们都在 FileOperation 类中,所以我可以像 fileOp.ResultData[] 一样访问它们。
有人可以帮我吗?
【问题讨论】:
标签: c# file winapi com dllimport