i want to program a downloader which works for slow networks. for example if i and a friend of mine are connected through a LAN .. i would want my downloader to download 1-50 % of xyz.file and my friend would download 51-100% of xyz.file ... (where xyz.file is any file to be downloaded from a website) . In the next stage the downloader would merge the files together to produce the original file.. i wish to program this thing using c# . Any help is welcome .. Please also tell me which classes/interfaces to study for this project of mine .. any kick-start code is also welcome ..
Regards
M Mohsin Ali
Multipart - networked downloader
Started by sp3tsnaz, Sep 01 2009 09:57 AM
17 replies to this topic
#1
Posted 01 September 2009 - 09:57 AM
|
|
|
#2
Posted 01 September 2009 - 12:53 PM
I'm not sure how I'd go about this, but how would this help? It won't change the throughput into your LAN.
#3
Posted 01 September 2009 - 09:47 PM
Well, downloading files from a web pages goes through WebRequest and WebResponse. But I never heard of downloading a file, partially and not from beginning. I imagine that if you can resume a download, then you could as well start it from some other point. But I do not have enough knowledge of how they work, I am sorry.
Splitting or joining files would be just few lines of code. That is the easy part, of course. Using FileStream classes would do it easily. ;)
Splitting or joining files would be just few lines of code. That is the easy part, of course. Using FileStream classes would do it easily. ;)
proudly presenting my personal website and game website: F1Simulation. a thrilling Managed DirectX racing game... also my Ask Me
look at my tutorials about cropping images and Mono: bundling Mono with programs and lambda expressions
look at my tutorials about cropping images and Mono: bundling Mono with programs and lambda expressions
#4
Posted 02 September 2009 - 08:40 AM
Some download managers can do things like that.
#5
Posted 02 September 2009 - 11:00 AM
WingedPanther said:
I'm not sure how I'd go about this, but how would this help? It won't change the throughput into your LAN.
#6
Posted 02 September 2009 - 11:02 AM
ArekBulski said:
Well, downloading files from a web pages goes through WebRequest and WebResponse. But I never heard of downloading a file, partially and not from beginning. I imagine that if you can resume a download, then you could as well start it from some other point. But I do not have enough knowledge of how they work, I am sorry.
Splitting or joining files would be just few lines of code. That is the easy part, of course. Using FileStream classes would do it easily. ;)
Splitting or joining files would be just few lines of code. That is the easy part, of course. Using FileStream classes would do it easily. ;)
#7
Posted 02 September 2009 - 11:20 AM
ArekBulski said:
Well, downloading files from a web pages goes through WebRequest and WebResponse. But I never heard of downloading a file, partially and not from beginning. I imagine that if you can resume a download, then you could as well start it from some other point. But I do not have enough knowledge of how they work, I am sorry.
Splitting or joining files would be just few lines of code. That is the easy part, of course. Using FileStream classes would do it easily. ;)
Splitting or joining files would be just few lines of code. That is the easy part, of course. Using FileStream classes would do it easily. ;)
which does the job .. im posting the sample code i grabbed from msdn .. let me know if im going in the rigth direction or not .. thankyou loads ..
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
// Create a New 'HttpWebRequest' object .
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create("some web address");
myHttpWebRequest.AddRange(50, 150);
// Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable.
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
// Display the contents of the page to the console.
Stream streamResponse = myHttpWebResponse.GetResponseStream();
StreamReader streamRead = new StreamReader(streamResponse);
Char[] readBuffer = new Char[256];
int count = streamRead.Read(readBuffer, 0, 256);
Console.WriteLine("\nThe HTML contents of the page from 50th to 150 charaters are :\n ");
while (count > 0)
{
String outputData = new String(readBuffer, 0, count);
Console.WriteLine(outputData);
count = streamRead.Read(readBuffer, 0, 256);
}
// Release the response object resources.
streamRead.Close();
streamResponse.Close();
myHttpWebResponse.Close();
Console.In.Read();
}
}
}
#8
Posted 02 September 2009 - 11:32 AM
msdn[dot]microsoft[dot]com[slash]en-us[slash]library[slash]aa329614(VS.71)[dot]aspx
sorry but i cant post the links .. im not permitted to.. replace [dot] with '.' in the above link :p and slash with /
sorry but i cant post the links .. im not permitted to.. replace [dot] with '.' in the above link :p and slash with /
Edited by sp3tsnaz, 03 September 2009 - 08:05 AM.
#9
Posted 02 September 2009 - 12:48 PM
Lol, removing "www." would do just fine. No need to turn it into a l33t code.
msdn.microsoft.com/en-us/library/aa329614(VS.71).aspx
So this is the method. I cannot say what it does, sorry.
HttpWebRequest.AddRange Method (Int32)
msdn.microsoft.com/en-us/library/aa329614(VS.71).aspx
So this is the method. I cannot say what it does, sorry.
HttpWebRequest.AddRange Method (Int32)
proudly presenting my personal website and game website: F1Simulation. a thrilling Managed DirectX racing game... also my Ask Me
look at my tutorials about cropping images and Mono: bundling Mono with programs and lambda expressions
look at my tutorials about cropping images and Mono: bundling Mono with programs and lambda expressions
#10
Posted 03 September 2009 - 05:29 AM
There you go, sp3tznaz. As you requested, a little elaboration about FileStream class. The second one is pretty neat IMO. :)
http://forum.codecal...ream-class.html
http://forum.codecal...le-methods.html
http://forum.codecal...ream-class.html
http://forum.codecal...le-methods.html
proudly presenting my personal website and game website: F1Simulation. a thrilling Managed DirectX racing game... also my Ask Me
look at my tutorials about cropping images and Mono: bundling Mono with programs and lambda expressions
look at my tutorials about cropping images and Mono: bundling Mono with programs and lambda expressions
#11
Posted 03 September 2009 - 08:08 AM
well !! i explored.. this Httpwebrequest is basically a class for Http protocol .. it doesnt have anything to do with downloading a file .. :(
#12
Posted 03 September 2009 - 08:28 AM
Well, WebRequest is indeed for downloading web pages, so I think it can also download files the same way, through http:// . You are on the right path, just dig deeper.
Never give up...never give up! :)
Never give up...never give up! :)
proudly presenting my personal website and game website: F1Simulation. a thrilling Managed DirectX racing game... also my Ask Me
look at my tutorials about cropping images and Mono: bundling Mono with programs and lambda expressions
look at my tutorials about cropping images and Mono: bundling Mono with programs and lambda expressions


Sign In
Create Account


Back to top









