-2

Is there any way to get the file details on which user clicks on Windows explorer using C# Windows application.

The user is not modifying, renaming or doing anything with the file, just clicks on a file and gets all details of that file on the click of the file. Like, trigger some event on windows application when the user clicks on any file.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • Instead of using Windows Explorer use equivalent FileDialog inside the c# application. – jdweng Jan 04 '19 at 16:29
  • @jdweng I want to get the file name clicked on windows explorer without any controls used for load files and list of it. – Bhavesh Vekariya Jan 04 '19 at 18:18
  • Is it is possible, but why do you care if the user selects a file? – Anders Jan 04 '19 at 18:28
  • It's *relatively* simple using UI Automation, if you want to try it. There's one *problematic* aspect of it: the ListView (`DUIListView`, the pane on the right), is destroyed each time the View changes or you select a Folder in the Left pane (`SysTreeView32`). So you need to handle a lot of events to be notified when the `DUIListView` is not `Current` anymore: It can't be cached and it needs to be renewed constantly. Except for this detail, it works well enough. – Jimi Jan 05 '19 at 07:09

1 Answers1

-1

I am not sure whether I have understood your question correctly, but here an idea:
You can build a windows application which consists of tree view which displays the file system (see this example). Then the user can browse in the treeview through different directories and files. When he clicks on a node you can display the information in a lable next to the treeview:

FileInfo fi1 = new FileInfo(pathOfTheClickedNode);
FileInfo fi = new FileInfo(path);
label1.Text = $"Filename: {fi.Name},\nLast Access Time: {fi.LastAccessTime},\nFile length: {fi.Length}";
Code Pope
  • 5,075
  • 8
  • 26
  • 68