windows form that can use HTTP

PHOTO EMBED

Wed Oct 29 2025 18:50:02 GMT+0000 (Coordinated Universal Time)

Saved by @final

select windowsformsapp(.net framework)
design the windows form
add a label, name it url
add a text box for url
add 2 buttons for download ,upload
add a label for res



webform1.cs:
using System;
using System.Net;
using System.Windows.Forms;

namespace upload
{
    public partial class Form1 : Form
    {
        WebClient client = new WebClient();
        public Form1()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            try { 
                string url = textBox1.Text.Trim(); 
                string filepath = "C:\\Users\\allam\\OneDrive\\Desktop\\download.txt";
                client.UploadFile(url, filepath);
                MessageBox.Show("file uploaded succesfully"); 
                label2.Text = "uploaded succesfully"; 
            } 
            catch (Exception ex) 
            { 
                label2.Text = "error: " + ex.Message;
            }

        }

        private void button1_Click(object sender, EventArgs e)
        {
            try { 
                string url = textBox1.Text.Trim(); 
                if (string.IsNullOrEmpty(url)) 
                { label1.Text = "please enter a download url";
                    return; 
                } 
                string savepath = "C:\\Users\\allam\\OneDrive\\Desktop\\download.txt"; 
                client.DownloadFile(url, savepath); 
                MessageBox.Show("File downloaded succesfully"); 
                label2.Text = "Downlpaded sucessfully"; 
            } 
            catch (Exception ex) 
            {
                label2.Text = "Error: " + ex.Message; 
            }
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }
    }
}
content_copyCOPY