We will be using WebRequest method because it will work as generic method for transparently retriving file from
- Web servers,
- FTP servers and
- File server
So
var httpRequest = WebRequest.Create("http://somedomain.com"); // return an instance of type(HttpWebRequest)
var ftpRequest = WebRequest.Create("ftp://ftp.somedomain.com"); // return an instance of type(FtpWebRequest)
var fileRequest = WebRequest.Create("file://files.somedomain.com"); // return an instance of type(FileWebRequest)
Return Type of all three methods (HttpWebRequest, FtpWebRequest, FileWebRequest) all drive from base class WebRequest which is return type of WebRequest.Create(string).
Now which subclass to instantiate is determined using the protocol prefixes (http:, https:, ftp:, file:)
So, any URI string (with any of these four prefixes) you pass to the Create method will be transparently handled by the WebRequest base class so you don't even have to know specifically what sub-class was returned