I want to build a software.
This software will just get the path of currently selected file.
Suppose I click a file on my desktop.
Now I want to get the path of this file.
So whenever a new selection is made just get the path of newly selected file.
Any ideas?
-
1You just want this on the desktop? – David Heffernan Aug 28 '11 at 11:18
3 Answers
The windows Desktop window is a ListView Control like in the end (at least it was in Windows XP...) so if you need to know selected item of a ListView you basically need to get the handle of the desktop and check what has been selected.
Not sure about windows Vista and 7 bit I guess it's not too different, as David has commented, if you want this for every single explorer window could be more difficult but should still be possible, have a look here for a start:

- 1
- 1

- 43,984
- 10
- 98
- 147
-
actually see here: http://stackoverflow.com/questions/7222749/i-created-a-program-to-hide-desktop-icons-on-double-click-of-desktop-but-would-on there is already the C# code to find the desktop. This does not solve your exact issue but you can copy a lot of code and see how it works to detect the double click on the desktop :) – Davide Piras Aug 28 '11 at 22:33
Maybe you should look at the OpenFileDialog class

- 8,228
- 4
- 36
- 56
-
and how could this help in detecting selected file in the desktop? – Davide Piras Aug 28 '11 at 11:36
-
As the question is vague I was wondering if he is looking to open a file in his application. Maybe not... – Shaun Wilde Aug 28 '11 at 11:40
I think you can use what Shaun had said about looking at OpenFileDialog.
You can also refer to this link below:
That link also teaches you how to change the title, filtering files of type and 1 or 2 others regarding OpenFileDialog.
Hope this helps.

- 51
- 3
- 10
-
1he does not need this, he wants to know on which file on the desktop or on the windows user interface the user has clicked and the file got selected. – Davide Piras Aug 28 '11 at 11:42