Trying to read the contents of a text file that resides on the Web.
The following code works fine.
However, if the file has an arbitrary extension other than .txt or .html, the GetResponse returns error 404, Not Found (even though the file exists.)
Is there any way I can read files with arbitrary extensions? For example, myFile.xyz.
` string url = @"http://www.xxxx.com/xxxx/myfile.txt";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
using (TextReader reader = new StreamReader(response.GetResponseStream()))
{
string s = reader.ReadToEnd();
Console.WriteLine(s);
}
}
`