C# 代理IP的winform

C# 代理IP的winform

python 复制代码
using System;
using System.Net;
using System.Windows.Forms;
 
namespace ProxyIPWinForms
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }
 
        private void btnSendRequest_Click(object sender, EventArgs e)
        {
            string proxyAddress = $"http://{txtProxyIP.Text}:{txtProxyPort.Text}";
            WebProxy proxy = new WebProxy(proxyAddress);
 
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://example.com");
            request.Proxy = proxy;
 
            try
            {
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                MessageBox.Show($"Status Code: {response.StatusCode}");
                response.Close();
            }
            catch (WebException ex)
            {
                MessageBox.Show($"Error: {ex.Message}");
            }
        }
    }
}
相关推荐
xuzhiqiang07247 小时前
Java进阶之路,Java程序员职业发展规划
java·开发语言
MediaTea7 小时前
Python:生成器表达式详解
开发语言·python
overmind9 小时前
oeasy Python 115 列表弹栈用pop删除指定索引
开发语言·python
Never_Satisfied9 小时前
在c#中,使用windows自带功能将文件夹打包为ZIP
开发语言·windows·c#
hnxaoli10 小时前
win10程序(十六)通达信参数清洗器
开发语言·python·小程序·股票·炒股
电饭叔10 小时前
文本为 “ok”、前景色为白色、背景色为红色,且点击后触发 processOK 回调函数的 tkinter 按钮
开发语言·python
Never_Satisfied11 小时前
在c#中,string.replace会替换所有满足条件的子字符串,如何只替换一次
开发语言·c#
Demon_Hao12 小时前
JAVA快速对接三方支付通道标准模版
java·开发语言
xyq202413 小时前
C# 判断语句详解与应用
开发语言