In my application, I generate a HTML file that I want to open by clicking on a button. So my file is named, for example:
QString file = "F:/the_path/to_the_/generated_html_file.html";
On Windows I change it to:
file = "file:///F:/the_path/to_the_/generated_html_file.html";
so that I can open it with :
QDesktopServices::openUrl(QUrl(file));
and it opens in the default browser.
But when the character #
is present in the path or file name, it doesn't work any more and it seems that the URL is truncated just after the #
.
For example, if I name the file generated#_html_file.html
, I get this error message:
ShellExecute 'F:/the_path/to_the_/generated' failed (error 2).
Why does that happen, and how can I avoid it?