最全文件监控之FileSystemWatcher(c++)_c+(1),2024年最新灵魂一问-如何彻底防止APK反编译

img
img

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化的资料的朋友,可以添加戳这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

  // Specify what is done when a file is renamed.
  Console::WriteLine( "File: {0} renamed to {1}", e->OldFullPath, e->FullPath );

}

public:
[PermissionSet(SecurityAction::Demand, Name=“FullTrust”)]
int static run()
{
//array<String>args = System::Environment::GetCommandLineArgs();
//创建一个FileSystemWatcher并设置它的属性.
FileSystemWatcher^ fsWatcher = gcnew FileSystemWatcher( );
fsWatcher->Path = “C:\files”;

  /* Watch for changes in LastAccess and LastWrite times, and
      the renaming of files or directories. */
  fsWatcher->NotifyFilter = static_cast<NotifyFilters>(//监听文件的以下属性 按需求添加  这里我添加了一些常用的
                            NotifyFilters::LastAccess | //文件或文件夹上一次打开的日期。 
                            NotifyFilters::LastWrite | //上一次向文件或文件夹写入内容的日期
                            NotifyFilters::FileName | //文件名
                            NotifyFilters::DirectoryName | //目录名
                            NotifyFilters::Size); //大小

  //监听子目录
  fsWatcher->IncludeSubdirectories = true;
  // Only watch text files.
  //fsWatcher->Filter = "*.txt";

  // Add event handlers.
  fsWatcher->Changed += gcnew FileSystemEventHandler( Watcher::OnChanged );
  fsWatcher->Created += gcnew FileSystemEventHandler( Watcher::OnChanged );
  fsWatcher->Deleted += gcnew FileSystemEventHandler( Watcher::OnChanged );
  fsWatcher->Renamed += gcnew RenamedEventHandler( Watcher::OnRenamed );

  // Begin watching.
  fsWatcher->EnableRaisingEvents = true;

  // Wait for the user to quit the program.
  Console::WriteLine( "Press \'q\' to quit the sample." );
  while ( Console::Read() != 'q' );

  return 0;

}
};

int main() {
Watcher::run();
}


过程 1.首先创建FileSystemWatcher 对象  用来设置一些属性以及添加监听事件


   2.设置监听目录


   3.设置监听文件的属性


   4.设置监听子目录


   5.添加监听事件


   6.开始监听


![img](https://img-blog.csdnimg.cn/img_convert/abc3a3621af39211a59c74bd42c98b57.png)
![img](https://img-blog.csdnimg.cn/img_convert/b0c63a98f12b38e8aac08c5d8c6f57a4.png)

**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**

**[需要这份系统化的资料的朋友,可以添加戳这里获取](https://bbs.csdn.net/topics/618668825)**


**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**

群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**

  • 3
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值