A similar question: How to avoid checking the file name in SaveFileDialog C #
I am writing an application that has the ability to support opening executable files and launching them with the given parameters, and I am trying to use it OpenFileDialogas a user-friendly way to achieve this. After tripping AddExtension, ValidateNames, CheckFileExistsand CheckPathExistsI can pass parameters to executable files, and application launches using their arguments as expected.
However, when I try to pass parameters containing "invalid" file names (for example, "/"), I stop and get the following message:

and I am not allowed to continue, even if the parameter is ValidateNamesset to false.
Here is the code related to the dialog box:
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 a way to resolve this and completely disable input validation, or do I need to write a custom file implementation?
source
share