-1

I know how works FileSystemWatcher in C#.

It allows us to give a message when file is already created.
no matter which program/process has created this file!
Or it allows us to give information about what is a name of created file, or when it was created "few second ago"...
Also it allows us to give a message about file which was deleted or changed.

But it does not allows us to create that kind of event:
when file is being creating, but it is not yet/still created!
what if I want to terminate or pause the file creation process programmatically?

For example I want to handle or terminate file creation process programmatically according it's information which tells us that size of this file is 4GB?
no matter which program/process is trying to create this file!

Or there is another question:
What if I want to calculate when was file creation started and when was it created? as well distance between this two dates!? I think you understood that we need more info about file before process will start to create it!

I think you might know that in windows 10 the explorer.exe allows us to do it anytime!

enter image description here

It even allows us to resume a copy process any time!
So if it is possible to do it in explorer.exe then it also might be possible to do it using .NET
But forget this resume capability of explorer.exe

I just need to cancel any file creation process for example if the size of this file is 4GB! no matter which program is trying to create file!

So please help me to find out How to pop up a messageBox during file creation process?


Thank you!
Sorry my bad English!

1 Answers1

1

The only way to be notified about the file operation before it is actually performed is to utilize a filesystem filter driver. This is a kernel-mode driver which you need to write in C. There exist samples of such drivers in the internet. An alternative to writing such driver yourself is to use one of the libraries that include pre-created filter drivers and let you handle all or chosen filesystem requests in user-mode (including .NET). Our company offers CallbackFilter product for this purpose.

Eugene Mayevski 'Callback
  • 45,135
  • 8
  • 71
  • 121