示例#1
0
        private void GenerateCode_Click(object sender, EventArgs e) // DOWNLOADS URL TO TEXT
        {
            string contents;

            TextArea.Clear();
            if (!string.IsNullOrWhiteSpace(URL.Text)) // checks if url is entered
            {
                using (var wc1 = new System.Net.WebClient())
                    try // checks for valid urls/404 errors etc and gives suitable error message to user
                    {
                        contents      = wc1.DownloadString(URL.Text);
                        TextArea.Text = contents;
                    }
                    catch (System.Net.WebException w)
                    {
                        MessageBox.Show(w.Message);
                        TextArea.Clear();
                    }
            }
        }