Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Reflection;
- using System.Windows.Forms;
- using System.Net;
- using System.Diagnostics;
- namespace WindowsFormsApplication1
- {
- public partial class MainForm : Form
- {
- public MainForm()
- {
- InitializeComponent();
- }
- private void textBox1_Enter(object sender, EventArgs e)
- {
- textBox1.Text = "";
- }
- private void button1_Click(object sender, EventArgs e)
- {
- string urlstring = textBox1.Text, source;
- if ((urlstring != "") && (urlstring.IndexOf("http://") != -1))
- using (WebClient wClient = new WebClient())
- {
- Uri url = new Uri(urlstring);
- source = wClient.DownloadString(url);
- textBox2.Text = source;
- /*Stopwatch t = new Stopwatch();
- t.Start();
- StreamWriter sw = new StreamWriter(Application.StartupPath+@"\result.txt");
- sw.WriteLine(source);
- sw.Close();*/
- if (!File.Exists(Application.StartupPath + @"\result.txt"))
- File.WriteAllText(Application.StartupPath + @"\result.txt", source);
- /*t.Stop();
- MessageBox.Show(t.Elapsed.ToString());*/
- }
- else MessageBox.Show("Неверный URL!");
- // MessageBox.Show(Application.StartupPath + "\\result.txt");
- }
- private void textBox1_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- button1.PerformClick();
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment