I need to use OpenFileDialog
to input a URI or local path. The problem is that the schema of the URL is not something windows knowns about (or should know about because it's a hack for testing).
I can turn off all validation and as long as I don't feed it a invalid chars it returns but then it will happily eat anything else and that isn't what I want either.
What I want is for it to accept valid local paths and correctly formatted URI's without validating the schema component of the Uri, that is the http
, ftp
or whatever at the start.
My current code is:
var dialog = new System.Windows.Forms.OpenFileDialog();
dialog.CheckFileExists = false;
dialog.CheckPathExists = false;
dialog.ValidateNames = false;
var result = dialog.ShowDialog();
if (result == System.Windows.Forms.DialogResult.OK)
return dialog.FileName;
If I feed the dialog foo://127.0.0.1/foo
it runs file to the last line and crashes with "The given path's format is not supported.
"
Why is it still trying to validate stuff?