Cocker

Untitled

Jul 25th, 2011
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.75 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Reflection;
  4. using System.Windows.Forms;
  5. using System.Net;
  6. using System.Diagnostics;
  7.  
  8. namespace WindowsFormsApplication1
  9. {
  10.     public partial class MainForm : Form
  11.     {
  12.         public MainForm()
  13.         {
  14.             InitializeComponent();
  15.         }
  16.  
  17.         private void textBox1_Enter(object sender, EventArgs e)
  18.         {
  19.             textBox1.Text = "";
  20.         }
  21.  
  22.         private void button1_Click(object sender, EventArgs e)
  23.         {
  24.             string urlstring = textBox1.Text, source;
  25.             if ((urlstring != "") && (urlstring.IndexOf("http://") != -1))
  26.                 using (WebClient wClient = new WebClient())
  27.                 {
  28.                     Uri url = new Uri(urlstring);
  29.                     source = wClient.DownloadString(url);
  30.                     textBox2.Text = source;
  31.                     /*Stopwatch t = new Stopwatch();
  32.                     t.Start();
  33.                     StreamWriter sw = new StreamWriter(Application.StartupPath+@"\result.txt");
  34.                     sw.WriteLine(source);
  35.                     sw.Close();*/
  36.                     if (!File.Exists(Application.StartupPath + @"\result.txt"))
  37.                         File.WriteAllText(Application.StartupPath + @"\result.txt", source);
  38.                     /*t.Stop();
  39.                     MessageBox.Show(t.Elapsed.ToString());*/
  40.                 }
  41.             else MessageBox.Show("Неверный URL!");
  42.            // MessageBox.Show(Application.StartupPath + "\\result.txt");
  43.         }
  44.  
  45.         private void textBox1_KeyDown(object sender, KeyEventArgs e)
  46.         {
  47.             if (e.KeyCode == Keys.Enter)
  48.             {
  49.                 button1.PerformClick();
  50.             }
  51.         }
  52.  
  53.  
  54.  
  55.  
  56.     }
  57. }
Add Comment
Please, Sign In to add comment