Reading from a file hosted on a server using C#

This post describes how to read a file which is hosted on server i.e on some url.

Let’s say I have a .txt file hosted here – I want my code to read from this hosted file. Below is how you do it using WebClient class.

var urlToReadFrom = ""
using(var client = new WebClient()) {
    string s = client.DownloadString(urlToReadFrom);
    return s;

Hope this helps.