当Windows资源管理器打开给定文件夹时调用方法

本文关键字:文件夹 调用 方法 Windows 资源管理器 | 更新日期: 2023-09-27 17:58:35

当用户在Windows资源管理器中打开文件夹时,我想执行一些C#方法。

怎么做这样的事?

当Windows资源管理器打开给定文件夹时调用方法

我对此不确定,但这是我会做/尝试的,

有一个登录时启动的C#程序在登录时打开C#应用程序,或者只是让你的程序以某种方式运行并使用FileSystemWatcher类。你可以使用LastAccess通知过滤器并执行你的C#代码。

    // Create a new FileSystemWatcher and set its properties.
    FileSystemWatcher watcher = new FileSystemWatcher();
    watcher.Path = "folder path";
     /* Watch for changes in LastAccess and LastWrite times, and
       the renaming of files or directories. */
    watcher.NotifyFilter = NotifyFilters.LastAccess;
    // add event handler

希望这能有所帮助。