0

When I call the following line, the dialog will show behind any floating dialogs, so I need to be able to set it to top most, or at least set the owner:

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

Unfortunately, I haven't found anything online that suggests this is doable. I understand I can create my own window and call into the API directly, but first I wanted to know if there was a way for all FileSystem dialogs to show topmost.

tshepang
  • 12,111
  • 21
  • 91
  • 136
jsirr13
  • 944
  • 2
  • 12
  • 38
  • maybe set topmost on the window that calls deletefile then set it back again. the delete file dialog comes from windows itself its not like openfiledialog or savefiledialog – RadioSpace Apr 01 '14 at 22:32
  • I already have a window that calls the line above. I've set the window to top most, it doesn't make a difference. Either way it's showing behind the window right now (between the window and the MainWindow). – jsirr13 Apr 01 '14 at 22:50
  • Are you referring to the VB compat `Microsoft.VisualBasic.FileIO` namespace? – Ben Voigt Apr 24 '14 at 22:19
  • The native COM interface, [`IFileOperation`](http://msdn.microsoft.com/en-us/library/bb775771.aspx) supports an owner window for the progress dialogs. – Ben Voigt Apr 24 '14 at 22:24
  • Yeah that's the namespace we are using. I'll look into IFileOperation – jsirr13 Apr 24 '14 at 23:37

1 Answers1

0

No answer, so I just set the messagebox parent to the form that's calling Show and just made API calls to recycle the deleted file:

            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);
            }

Where the method "send" is part of a wrapper class exposed here

Community
  • 1
  • 1
jsirr13
  • 944
  • 2
  • 12
  • 38