#pragma once
namespace CPP_WinForms {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Net;
using namespace System::IO;
/// <summary>
/// Summary for Form1
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::TextBox^ textBox1;
protected:
private: System::Windows::Forms::Button^ button1;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->button1 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// textBox1
//
this->textBox1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom)
| System::Windows::Forms::AnchorStyles::Left)
| System::Windows::Forms::AnchorStyles::Right));
this->textBox1->Location = System::Drawing::Point(12, 12);
this->textBox1->Multiline = true;
this->textBox1->Name = L"textBox1";
this->textBox1->ScrollBars = System::Windows::Forms::ScrollBars::Both;
this->textBox1->Size = System::Drawing::Size(611, 473);
this->textBox1->TabIndex = 0;
//
// button1
//
this->button1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left));
this->button1->Location = System::Drawing::Point(12, 491);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 23);
this->button1->TabIndex = 1;
this->button1->Text = L"Request";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(635, 517);
this->Controls->Add(this->button1);
this->Controls->Add(this->textBox1);
this->Name = L"Form1";
this->Text = L"Form1";
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
WebRequest^ Request = WebRequest::Create("http://lleo.aha.ru/na/");
WebResponse^ Response = Request->GetResponse();
StreamReader^ SR = gcnew StreamReader(Response->GetResponseStream(), System::Text::Encoding::GetEncoding("Windows-1251"));
String^ S = SR->ReadToEnd();
textBox1->Text=S;
}
};
}
private void button1_Click(object sender, EventArgs e)
{
WebRequest Request = WebRequest.Create("http://lleo.aha.ru/na/");
WebResponse Response = Request.GetResponse();
StreamReader SR = new StreamReader(Response.GetResponseStream(), System.Text.Encoding.GetEncoding("Windows-1251"));
String S = SR->ReadToEnd();
textBox1->Text=S;
}
using System;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Collections.Generic;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
button1.Dock = DockStyle.Bottom;
button2.Dock = DockStyle.Bottom;
textBox1.Multiline = true;
textBox1.Dock = DockStyle.Fill;
textBox1.WordWrap = false;
textBox1.ScrollBars = ScrollBars.Both;
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = GetTextFile("http://exler.ru", Encoding.GetEncoding("Windows-1251"));
}
//Возвращаем текст целиком
private static String GetTextFile(String Link, Encoding Encoding)
{
WebRequest Request = WebRequest.Create(Link);
WebResponse Response = Request.GetResponse();
StreamReader SR = new StreamReader(Response.GetResponseStream(), Encoding);
return SR.ReadToEnd();
}
private void button2_Click(object sender, EventArgs e)
{
List<String> Strings = GetTextStrings("http://exler.ru", Encoding.GetEncoding("Windows-1251"));
textBox1.Lines = Strings.ToArray();
}
//Возвращаем список строк
private static List<String> GetTextStrings(String Link, Encoding Encoding)
{
WebRequest Request = WebRequest.Create(Link);
WebResponse Response = Request.GetResponse();
StreamReader SR = new StreamReader(Response.GetResponseStream(), Encoding);
List<String> Strings = new List<String>();
String S;
while ((S = SR.ReadLine()) != null)
Strings.Add(S);
return Strings;
}
}
}
Если Вы уже зарегистрированы на Портале - войдите в систему, если Вы еще не регистрировались - пройдите простую процедуру регистрации.