Reputation: 1
I'm making an antivirus scanner in C# language in windows forms. With the current code the program can open a folder and start scanning the files in it. When the folder selected is 'my computer' or 'user profiles' it is showing a lot of exceptions and it stops scanning at that moment. I would like any one to please demonstrate me on how to solve this problem.
The exceptions were:
System.IO.IOException
, System.UnauthorizedAccessException
and many more.
I would like to show you some parts of the code. The image is available here. I wanted to paste the code here but my institution is strict against plagiarism.
Please help me resolve my situation.
Thank You
Upvotes: 0
Views: 146
Reputation: 28316
You can't scan "My Computer" or "User Profiles" because they're not directories, they're simply nodes in the standard directory tree browser control designed to allow the user to access certain types of location.
If you want them to be able to scan such folders, you need to detect that they've picked one and provide your own logic to enumerate the locations to scan.
On a slight tangent, I sincerely hope you're not planning on using this project as a replacement for a real AV package. It's no trivial task to build an anti-malware system, especially when you consider the types of attacks you need to block. If this is just for learning purposes, then that's fine, but don't expect even the slightest level of increased security from a homebrew design. A proper AV package needs a large database of detection signatures (static hashes, fuzzy hashes, data patterns), a kernel-mode component, a memory scanner, and behavioural analysis. It's difficult to build all this yourself.
(source: I wrote one myself, as a for-fun project!)
Upvotes: 1