Solved

Download from URL using proxy server and batch file

Posted on 2016-08-31
2
86 Views
Last Modified: 2016-09-07
The program below allows me to download from a URL on a proxy server.
Is it possible to do the same using a batch file?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
namespace WebDownloader
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                //WebClient client = new WebClient();

                WebProxy webProxy = new WebProxy("ftpproxy");
                WebClient client = new WebClient();
                client.Proxy = webProxy;

                //client.Proxy.Credentials = new NetworkCredential("myusername", "mypassword");
                //client.Proxy.GetProxy(new Uri("proxy.server.com:8080"));
                string Webpage = client.DownloadString("https://www.site.com/xmlfeed/xml_prices_full.asp?code=99201&user=xxx&pass=yyy");
                using (StreamWriter sw = new StreamWriter("O:\\Data_Download\\site\\SupplierFile.txt"))
                {
                    sw.Write(Webpage);
                }
                Webpage = client.DownloadString("https://www.site.com/xmlfeed/xml_prices_full.asp?code=99221&user=zzz&pass=qqq");
                using (StreamWriter sw = new StreamWriter("O:\\Data_Download\\site\\SupplierFileMBIO.txt"))
                {
                    sw.Write(Webpage);
                }

                Environment.Exit(0);
            }
            catch (Exception ex)
            {
                using (StreamWriter sw2 = new StreamWriter("O:\\Loaders\\Global\\site\\Commodities\\Price\\Errors\\DownloadError.txt"))
                {
                    sw2.Write(ex.Message);
                    
                }
                Environment.Exit(1);
            }
        }
    }
}

Open in new window

0
Comment
Question by:AlHal2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 84

Accepted Solution

by:
oBdA earned 500 total points
ID: 41777708
For example with curl.exe: https://curl.haxx.se/download.html
Or with Invoke-WebRequest from Powershell.
0
 

Author Closing Comment

by:AlHal2
ID: 41787611
Thanks.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
In this article, I will show you HOW TO: Perform a Physical to Virtual (P2V) Conversion the easy way from a computer backup (image).
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question