如何检测新文件下载 [英] How can I detect a new file download

查看:66
本文介绍了如何检测新文件下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿所有,



我正在用c#编写反恶意软件包,我想在应用程序中添加的功能之一就是尽快下载开始然后应用程序将检测它并将其与已知的损坏文件进行比较。这有可能吗?



我尝试过:



我尝试让它作为服务运行,但应用程序不会对下载做出反应。

Hey All,

I am writing a anti-malware package in c# and one of the features I would like to add to the application is that as soon as a download begins then the application would detect it and compare it to known corrupt files. Is this even possible?

What I have tried:

I have tried to have it run as a service but the application doesn't react to downloads.

推荐答案

您可以使用C#中的文件系统观察程序类来检测新文件下载。



FileSystemWatcher类(System.IO) [ ^ ]



通过以下活动,您可以执行以下任何操作文件被更改/更新/删除。



You can use the file system watcher class in C# to detect new file downloads.

FileSystemWatcher Class (System.IO)[^]

With the following events, you can do anything you need when a file is altered/updated/deleted.

watcher.Changed += new FileSystemEventHandler(OnChanged);
watcher.Created += new FileSystemEventHandler(OnChanged);
watcher.Deleted += new FileSystemEventHandler(OnChanged);
watcher.Renamed += new RenamedEventHandler(OnRenamed);





请记住,这必须作为Windows服务实现,以持续监控目录。



我提供的链接提供了您需要做什么的示例使FileSystemWatcher类工作。



Keep in mind this would have to be implemented as a windows service to continuously monitor a directory.

The link i provided provides samples for what you need to do to make FileSystemWatcher class work.


这篇关于如何检测新文件下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆