string url = textBox1.Text.Trim();
if (string.IsNullOrEmpty(url))
{
MessageBox.Show("Please enter a URL.");
return;
}
// Save to Documents folder
string localPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\downloaded_file.txt";
try
{
using (WebClient client = new WebClient())
{
client.DownloadFile(url, localPath);
}
MessageBox.Show($" File downloaded successfully to:\n{localPath}");
}
catch (Exception ex)
{
MessageBox.Show(" Error: " + ex.Message);
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter