Question

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.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top