【问题标题】:How to show FileSystem.DeleteFile dialog as top most or set the parent/owner?如何将 FileSystem.DeleteFile 对话框显示为最顶层或设置父/所有者?
【发布时间】:2014-04-01 22:25:55
【问题描述】:

当我调用以下行时,对话框将显示在任何浮动对话框的后面,因此我需要能够将其设置为最顶部,或者至少设置所有者:

FileSystem.DeleteFile(someString, UIOption.AllDialogs, RecycleOption.SendToRecycleBin);

不幸的是,我没有在网上找到任何表明这是可行的。我知道我可以创建自己的窗口并直接调用 API,但首先我想知道是否有办法让所有文件系统对话框都显示在最顶层。

【问题讨论】:

  • 可能会在调用 deletefile 的窗口上设置最顶部,然后再将其设置回来。删除文件对话框来自 Windows 本身,它不像 openfiledialog 或 savefiledialog
  • 我已经有一个窗口可以调用上面的行。我已将窗口设置为最顶部,它没有任何区别。无论哪种方式,它现在都显示在窗口后面(在窗口和主窗口之间)。
  • 你指的是VB兼容Microsoft.VisualBasic.FileIO命名空间吗?
  • 原生 COM 接口 IFileOperation 支持进度对话框的所有者窗口。
  • 是的,这就是我们正在使用的命名空间。我会研究 IFileOperation

标签: c# file-io filesystems owner topmost


【解决方案1】:

没有答案,所以我只是将消息框父级设置为调用 Show 的表单,并进行 API 调用以回收已删除的文件:

            string message = string.Format("Are you sure you want to move '{0}' to the recycling bin?", Path.GetFileNameWithoutExtension(path));
            var result = MessageBox.Show(this, message, @"Move To Recycling Bin?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            if (result == DialogResult.Yes)
            {
                Send(path, FileOperationFlags.FOF_NOCONFIRMATION | FileOperationFlags.FOF_NOERRORUI | FileOperationFlags.FOF_SILENT);
            }

方法“send”是暴露here的包装类的一部分

【讨论】:

    猜你喜欢
    • 2021-03-25
    • 1970-01-01
    • 2010-10-11
    • 1970-01-01
    • 1970-01-01
    • 2013-02-05
    • 1970-01-01
    • 2019-04-30
    • 1970-01-01
    相关资源
    最近更新 更多