Selenium: download file in Internet Explorer to specified folder without direct link, without Windows Forms, without AutoIt or Robot

I’ve often faced an issue, how to download files in IE.
In contrast to Chrome of Firefox, you cannot just specify required folder, and all the files will be downloaded to that folder. You also need to interact with native Windows forms and so on.

There are multiple options, like using AutoIt, using keyboard commands, Robot and etc… But all this options aren’t stable, they require explicit waiting, using redundant libraries, and non-appropriate when run tests in parallel. The other problem, is what to do, if the file isn’t downloaded by direct link, but link is generated from javascript command or received from server, and cannot be extracted from html.

All these problems can be solved, here in hte answer i’ll show how to do it.
Solution is written in c#, i believe the same can be implemented in java