hi, i use this code for read text file from internet, but When the user clicks on the button The program is closed.
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using System.Net;
using System.IO;
Button button = FindViewById<Button>(Resource.Id.button1);
var txt = FindViewById<TextView>(Resource.Id.textView1);
button.Click += (sender, e) =>
{
txt.Text = ShowRemoteStringFile("http://shadoow.ir/adress/BNJfilmha.txt");
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.SetTitle("AriaVPN Address Finder");
builder.SetIcon(Android.Resource.Drawable.IcDialogAlert);
builder.SetMessage("New Address Found : \n " + txt.Text);
builder.Show();
};
private string ShowRemoteStringFile(string url)
{
WebRequest req = WebRequest.Create(url);
WebResponse rsp = (HttpWebResponse)req.GetResponse();
StreamReader rdr = new StreamReader(rsp.GetResponseStream());
string result = rdr.ReadToEnd();
return result;
}