'How can I block IP addresses through Windows Firewall with C#

I have a C# application to block an website. And this is my code:

blsite.StartInfo.FileName = ("powershell.exe");
blsite.StartInfo.UseShellExecute = false;
blsite.StartInfo.Arguments = "New-NetFirewallRule -DisplayName 'Block-example_com' -Direction Outbound –LocalPort Any -Protocol Any -Action Block -RemoteAddress 93.184.216.34";
blsite.Start();
blsite.WaitForExit();

I have run it, but it didn't work, even though in Windows Defender Firewall showed my rule.

I tried removing that rule, and running the above command directly through powershell got the result that the page was blocked.

Sorry for my poor English



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source