-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCode.cs
30 lines (29 loc) · 1.25 KB
/
Code.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
private static void Download_WebFiles(string Web_URL, string Local_Path)
{
WebClient client = new WebClient();
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Web_URL);
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
string html = reader.ReadToEnd();
Regex regex = new Regex(Get_Files(Web_URL));
MatchCollection matches = regex.Matches(html);
if (matches.Count > 0)
{
foreach (Match match in matches)
{
if (match.Success)
{
string WebFileName=match.Groups["name"].ToString();
client.DownloadFile(Web_URL + WebFileName, Local_Path + "\\"+WebFileName);
}
}
}
}
}
}
private static void Get_Files()
{
return "<a href=\".*\">(?<name>.*)</a>"
}