title: Create firewall rule to open port per application programmatically in c#
body: <p>I need to open specific port for my application.</p>
  
  <p>I have tried using <code>INetFwAuthorizedApplication</code> rule per application for all ports.</p>
  
  <pre><code>fwMgr.LocalPolicy.CurrentProfile.AuthorizedApplications.Add(app)
  </code></pre>
  
  <p>Alternatively open one port for all appllications using <code>INetFwOpenPort</code>.</p>
  
  <pre><code>firewallManager.LocalPolicy.CurrentProfile.GloballyOpenPorts.Add(port)
  </code></pre>
  
  <p>Is there any way to programmatically open only single port per application programmatically?
  I can do it manually through firewall settings.</p>