日期:2014-05-18 浏览次数:20955 次
NATUPNPLib.IStaticPortMappingCollection mapping = nat.StaticPortMappingCollection; int i = 0; NATUPNPLib.IStaticPortMapping smap; IEnumerator mapEm = mapping.GetEnumerator(); mapEm.Reset(); while (i < mapping.Count) { mapEm.MoveNext(); smap = mapEm.Current as IStaticPortMapping; if (smap != null) { this.listBox1.Items.Add(smap.ExternalPort + "\t" + smap.InternalClient + "\t" + smap.Protocol + "\t" + smap.InternalPort); } if (smap == null) { break; } i++; }
NATUPNPLib.IStaticPortMappingCollection mapping = nat.StaticPortMappingCollection; NATUPNPLib.IStaticPortMapping smap; IEnumerator mapEm = mapping.GetEnumerator(); mapEm.Reset(); while (mapEm.MoveNext()) { smap = mapEm.Current as IStaticPortMapping; if (smap == null) { break; } this.listBox1.Items.Add(smap.ExternalPort + "\t" + smap.InternalClient + "\t" + smap.Protocol + "\t" + smap.InternalPort); }
------解决方案--------------------
NATUPNPLib.IStaticPortMapping smap = mapping[0, string.Empty];
------解决方案--------------------
我的机子上 NATUPNPLib.IStaticPortMappingCollection mapping = nat.StaticPortMappingCollection;
mapping一直为Null。帮不了你。