c# - How to implement file downloader to detect communication breakage? -
i need implement file downloader in c#. downloader running on client computer, , download several files according several conditions.
the main restriction have client go offline during downloading (sometime more once), need following things happen:
1) downloader should notice there isn’t network communication anymore , pause downloading.
2) downloader should resume downloading once communication back, , continue collecting packages, adding them downloaded local disk.
i have checked stackoverflow previous posts , saw there 2 options – webclient , webrequest (using 1 of inheritance classes). wondering if can advise 1 use based on requirements have specified. how can detect communication breakage?
you need system.net.httpwebrequest send http requests , system.io.filestream access files. 2 methods needed httpwebrequest.addrange , filestream.seek
httpwebrequest.addrange method adds byte range header request, , range parameter specifies starting point of range. server start sending data range parameter specified end of data in http entity. while filestream.seek method used access current position within stream.
Comments
Post a Comment