日期:2014-05-19  浏览次数:21009 次

C#程序如何通过http代理访问网络?
比如pop.yeah.net

这是现在的代码。
                        TcpClient   tcpClient   =   new   TcpClient(this.HostName,this.Port);
                        NetworkStream   ns   =   tcpClient.GetStream();
                        StreamReader   rs   =   new   StreamReader(ns);

                        rs.ReadLine();

                        string   data;
                        if   (context   ==   null)
                        {
                                data   =   command   +   "\r\n ";
                        }
                        else
                        {
                                data   =   command   +   "   "   +   context   +   "\r\n ";
                        }

                        byte[]   bytesData   =   Encoding.ASCII.GetBytes(data);

                        try
                        {
                                ns.Write(bytesData,   0,   bytesData.Length);
                                Debug.WriteLine(rs.ReadLine());
                        }
                        catch   (Exception   ex)
                        {
                                Debug.WriteLine(ex.Message);
                        }

------解决方案--------------------
up
------解决方案--------------------
用webclient吧,有代理属性

------解决方案--------------------
用C#通过修改注册表改变IE的代理设置访问网络,同一个程序集用两个不同代理访问,还不知道怎么实现,期待高手!