OpenFileDialog does not allow the "/" character even after disabling validation

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:

Verification message example

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?

+1
source share
1 answer

You cannot override the default check. Thus, you will either have to request the parameters in a separate dialog, or restart the file open dialog.

0
source

Source: https://habr.com/ru/post/1533579/


All Articles