Saturday, 24 August 2013

Downloading files using download manager in C#

Downloading files using download manager in C#

I am creating download manager in C#.I am currently designing download
component that given URL, download files from the URL in segments.

I am currently using I/O streams for each chunks as shown below:
MyChunks.InputStream = rs ; //rs is obtained by using GetResponse() from
FtpWebRequest
MyChunks.OutputStream = fs ; //fs is FileStream for writing on local file
chunksize = MyChunks.InputStream.Read(buffer, 0, bufferSize);
MyChunks.OutputStream.Write(buffer, 0, (int)chunksize);
Regarding other methods that I analysed I found that I can also use
`WebClient.DownloadDataAsync` Method.
However, I can't take advantage of chunks of data downloaded on multiple
threads to speed up download.However, Above code is working fine.

My question is if there are any other ways available to download chunks or
above code is just fine?
Also, I want to play audio(mp3)/video files as they are downloaded can you
suggest method for doing the same?

No comments:

Post a Comment