-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSave_html_page.cs
50 lines (46 loc) · 1.68 KB
/
Save_html_page.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Net;
namespace Intensive
{
class Save_html_page
{
public string urI;
public Save_html_page()
{
}
public Save_html_page(string URI)
{
urI = URI;
}
string desktop_path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\download_html_file.html";// { get; set; }
public string Desktop_path
{
get { return desktop_path; }
}
public Uri uri;
internal void Get_data_from_HTML_page()
{
WebClient client = new WebClient();
try
{
uri = new Uri(urI);
Console.WriteLine("Проверяется URI-адрес");
client.DownloadFile(uri, desktop_path);
Console.WriteLine("URI-адрес верный");
Console.WriteLine("Файл скачан на рабочий стол");
}
catch (UriFormatException)
{
Console.WriteLine("Введен не верный URI, нажмите любую кнопку, чтобы выйти из программы");
Console.ReadKey();
Environment.Exit(1);
}
catch (WebException)
{
Console.WriteLine("Отсутствует подключение к интернету, либо такого URI не существует, нажмите любую кнопку, чтобы выйти из программы");
Console.ReadKey();
Environment.Exit(1);
}
}
}
}