Can't open selected file in windows explorer from application
-
Hi
are u sure the "/select," << comma is correct ? -
@mrjj
I took that from
https://stackoverflow.com/questions/3490336/how-to-reveal-in-finder-or-show-in-explorer-with-qt
and
http://lynxline.com/show-in-finder-show-in-explorer/
Yes, there it seems to work -
Ok.
Its also possible to use Desktop services and do
QDesktopServices::openUrl(QUrl("file:///home/xx/fileName.pdf"));
to open it in default app,
but you seem to want to open explorer and have it selected?
(which samples is for. not to launch the app for edit. )update:
it works here
it will open folder select the file. as it should.
(it does not open the file but that is not expected) -
Ok.
Its also possible to use Desktop services and do
QDesktopServices::openUrl(QUrl("file:///home/xx/fileName.pdf"));
to open it in default app,
but you seem to want to open explorer and have it selected?
(which samples is for. not to launch the app for edit. )update:
it works here
it will open folder select the file. as it should.
(it does not open the file but that is not expected)@mrjj
Yes, I create several text files while runtime and by clicking on a button, I want to open one specific (depending on the button) selected in the explorer (not in a text editor), not in the browserupdate
well I found a text file, that works (I just tried randomly):// this works args << "/select," << QDir::toNativeSeparators("C:/Program Files/Autodesk/Maya2018/bin/MTTH.txt"); QProcess::startDetached("explorer", args);
but yet I could not find any other text file, that works. Not on the G disk, not on the C, that's the only one
-
@mrjj
Yes, I create several text files while runtime and by clicking on a button, I want to open one specific (depending on the button) selected in the explorer (not in a text editor), not in the browserupdate
well I found a text file, that works (I just tried randomly):// this works args << "/select," << QDir::toNativeSeparators("C:/Program Files/Autodesk/Maya2018/bin/MTTH.txt"); QProcess::startDetached("explorer", args);
but yet I could not find any other text file, that works. Not on the G disk, not on the C, that's the only one
@Niagarer
so it should just open explorer and show file as selected ?you code works for me on win 10.
It will open the drive and have the file selected.QStringList args; args << "/select," << QDir::toNativeSeparators("c:/degree-angles.png"); QProcess::startDetached("explorer", args);
Tried a few different file and all types seems to work.
-
@Niagarer
so it should just open explorer and show file as selected ?you code works for me on win 10.
It will open the drive and have the file selected.QStringList args; args << "/select," << QDir::toNativeSeparators("c:/degree-angles.png"); QProcess::startDetached("explorer", args);
Tried a few different file and all types seems to work.
@mrjj
Ok weird then, I also tried on win 10 ...
I can't find differences between the files I tried... only MTTH.txt worksupdate
Oh, ok it seems to be a general problem with my system... I also can't open it from cmd like you tried... it opens my dcuments then... So it seems not to be a qt problem -
@mrjj
Ok weird then, I also tried on win 10 ...
I can't find differences between the files I tried... only MTTH.txt worksupdate
Oh, ok it seems to be a general problem with my system... I also can't open it from cmd like you tried... it opens my dcuments then... So it seems not to be a qt problem -
@Niagarer
All files work here. Even folders.
I also tried other drives and so i agree must be something locally
in your system. ( no idea what though)@mrjj
Ok, yes I even can't open the MTTH.txt file from cmd, it just opens my documents folder every time...
I have no idea... I hope I can fix this
Thanks for your help!I can open the files with a notepad, but not with the explorer. So my explorer seems to be sick.
I will update anyways when I have a solution -
Hi
For test, try disable any extra virus scanner you have installed. -
@Niagarer
Would have been too easy. ;)did you try with quotes ?
explorer.exe /select,"e:\test.txt"
(in cmd)@mrjj
Yup, unfortunately also no solution... but then it does not open my documents folder, it just open the explorer
Slowly but surely it start to get funnyupdate
When I try to select, it just opens the explorer, if not, it opens the documents folder -
well it does open docs here too if no /select
if i do
.. /select,"file that dont exists"
it opens "This PC" -
well it does open docs here too if no /select
if i do
.. /select,"file that dont exists"
it opens "This PC"@mrjj
yes, the weird thing is, that the explorer defiantely knows the file. I even can search in the explorer search line and it finds the file.
But as you wrote, from cmd it can't find the file...
I can navigate to the right folder on the G drive, it still can't find the file -
@mrjj
yes, the weird thing is, that the explorer defiantely knows the file. I even can search in the explorer search line and it finds the file.
But as you wrote, from cmd it can't find the file...
I can navigate to the right folder on the G drive, it still can't find the file -
@Niagarer
But its only /select that is broken correct?
if you do other commands it does work?
like
type e:\test.txt -
@mrjj
No, I don't think so.
All the following commands don't work:// here it says, it could find that file... it is definately there notepad G:/test.txt explorer G:/ explorer /select G:/test.txt
-
Oh
in cmd
you must use \ that slash. not / .Qt makes it possible to use / but windows dont know it natively.
-
Oh
in cmd
you must use \ that slash. not / .Qt makes it possible to use / but windows dont know it natively.
@mrjj
Ok, I got it. Yes G is just another drive and it didn't work on any drive because:
I also noticed this \ and / thing and this was one of my mistakes.
Another thing, why cmd could not find one of my test.txt files I tried to open was that I named it test.txt (so the actual file name was test.txt.txt as my browser told me <facepalm x3>).
And one last thing, that is no less stupid is, that I sent the path from another object and this object did not send the .txt ending. Baad day :D
And I copied the path of some text files from the explorer and tried these, but the \ made it not working.
I thought thatQDir::toNativeSeperators(pathIn);
would fix \ to / (or \ on windows), but that seems to be wrong. It just takes normal paths with / and translates it to \ on windows http://doc.qt.io/qt-4.8/qdir.html#toNativeSeparators
Thank you very much for you help!
-
Ahh that is a classic :)))
I forgot about it.
Most stupid settings the history of windows as renaming the file will not actually work and you
get 2 x extension.