0

I am trying to display the contents of a text file hosted on a server within a richtextbox but am having an error stating URI formats are not supported.

If I access the txt file from my local drive I can do the following:

public void ReadFile() {

TextReader reader = File.OpenText(@"help.txt");
richtextBox1.Text = reader.ReadToEnd();        
}

How can i have the same outcome with a remote file?

The txt file is accessed via http. the Url for example is:

Http://www.example.com/help.txt

M.kazem Akhgary
  • 18,645
  • 8
  • 57
  • 118
user1505181
  • 61
  • 1
  • 1
  • 11

1 Answers1

1

You could do this:

System.Net.WebClient wc = new System.Net.WebClient();
string url_data = wc.DownloadString("http://example.com/1.txt");
richtextBox1.Text = url_data;

Hope this helps.

Aidon Hudson
  • 124
  • 8