0

Is there any way to get the name and path of a file that user opens in windows 7. What sort of api's can be used?

I have made a win form that retrieves currently opened applications and recently used files. While looking onto the file section, I can't open the file because it's an .ink shortcut. So i found another way to get those files(not yet completed, only idea). To make a service that tracks files that have been opened by user. By doing this, I can add it into my app and categorize files using other extension. i.e, music files, video files and etc.

My question is can I get the name and path of files that user opened.

sajadre
  • 1,141
  • 2
  • 15
  • 30
  • 2
    Please insert the code that is written. Do you use the `openFileDialog`? – topcool May 18 '19 at 09:27
  • 1
    The most *accessible* way is probably to monitor the `Recent Files` folder using a FileSystemWatcher. The `.LNK` of the file (and the container folder) is updated when a user opens a File. The content of a `.LNK` can be accessed using the Shell. For example: [Get target of shortcut folder](https://stackoverflow.com/a/9414495/7444103). Other, more *low level*, options are available, but this is quite simple and relatively reliable (for common user files). – Jimi May 18 '19 at 10:09
  • Another could be to enable the NTFS `Last Access` record of a file (FileSystemWatcher can notify this change). This is also relatively simple, but there's also a reason why this feature is usually disabled. – Jimi May 18 '19 at 10:15
  • As i mentioned, i did used recent files and added it to my app. But it's an .lnk shortcut. I can't directly open it from my app. I have surfed through whole internet but cant find the right solution to it. That's why i choose this tracking method. Ie, using service in the background to check which files have been opened by the user. So the user can easily access the file from my app when needed. If you can't get what iam talking about, i will explain my project to you. If needed! Thanks for the .lnk solution though. – Fazil Aboobacker May 18 '19 at 12:01
  • Are you using IFormFile in the input of your api action? – sajadre May 19 '19 at 11:39

0 Answers0