I have a peculiar problem, I have created a code to be able to organize and execute shortcuts, but my problem is with the OpenFileDialog Class.
After having put a filter on it, so that it only finds .exe, it turns out that it is unable to differentiate between an .exe and a .url that imitates an .exe.
OpenFileDialog file = new OpenFileDialog();
file.Filter = "Executable (*.exe)|*.exe";
if (file.ShowDialog() == DialogResult.OK && file.CheckPathExists && file.CheckFileExists)
{
textResult.ReadOnly = false;
textResult.Text = System.IO.Path.GetFullPath(file.FileName);
textResult.ReadOnly = true;
}
In the image set as despite the .exe filter, it shows both the direct access of the .exe and that of a url and if you select the one of the url, "Catastrophic failure" appears.
Any ideas?.
I found a solution.
The original problem was that when I searched for .exe, .url appeared, which were shortcuts to, for example, steam games.
The solution was:
Add to the filter a mixed filter between .exe and .url, in this way that when trying to execute a direct access of that type it would not give an error.