Similar question: How to avoid of file name validation in SaveFileDialog C#
I am writing an application that has an option to support opening executables and running them with given parameters, and I am trying to use OpenFileDialog
as a user-friendly way to achieve this. After disabling AddExtension
, ValidateNames
, CheckFileExists
and CheckPathExists
, I can pass parameters to executables and the application runs them using the arguments as intended.
However, when I attempt to pass parameters that include "invalid" filename characters (such as '/'), I am stopped and get this example message:
and am not allowed to continue, even though ValidateNames
is set to false.
Here is the code concerning the dialog:
OpenFileDialog dialog = new OpenFileDialog();
dialog.AddExtension = false;
dialog.CheckFileExists = false;
dialog.CheckPathExists = false;
dialog.ValidateNames = false;
if (dialog.ShowDialog() == DialogResult.OK) {
//Parse text manually here (parsing is fully handled on the developer side)
}
Is there any way to resolve this and completely disable input validation, or do I have to write a custom file dialog implementation?