Reputation: 7825
There are wireless adapter and dial-up modem connected to network. And there are two files, which we need to download. (file1 & file2)
Can I download two different files via different network adapters simultaneously using C#? For example: file1 should be downloaded through wireless adapter, and file2 via dial-up.
OS Win7
Upvotes: 1
Views: 621
Reputation: 120450
You can choose your outgoing IP address in a WebRequest as follows:
string sendingIp = "192.168.0.1";
int sendingPort = 5000;
Uri uri = new Uri("http://google.com");
HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(uri);
ServicePoint sp = ServicePointManager.FindServicePoint(uri);
sp.BindIPEndPointDelegate =
(servicePoint,remoteEp,retryCount) =>
{
return new IPEndPoint(IPAddress.Parse(sendingIp),sendingPort);
};
var data = new StreamReader(wr.GetResponse().GetResponseStream()).ReadToEnd();
This code does not deal with disposal correctly.
Upvotes: 3