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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using System.Xml; using System.Xml.XPath; using System.Collections; using System.Net;
namespace WebFiles
{
class CDownloadWebFiles
{
const string fileLinks = "Links/links.txt";
private ArrayList addresses;
private string[] links;
public void downloadWebFiles()
{
this.getLinks();
getWebPage();
download();
}
protected void getLinks()
{
char[] delimiterChars = { '\r', '\n', '\t',' ' };
int it;
int jt;
for (it=0; it<this.addresses.Length;it++)
{
for (jt=0; jt < this.addresses.Length; jt++)
{
string[] content = Directory.GetFiles(this.addresses[jt]);
this.addresses= content[jt].Split(delimiterChars);
}
}
}
protected void getWebPage()
{
string link;
foreach (string[]links in link)
{
XmlDocument doc = new XmlDocument();
doc.Load(link);
XmlNodeList elemList = doc.GetElementsByTagName("a");
int i;
for (i = 0; i < elemList.Count; i++)
{
this.addresses=(elemList[i].InnerXml);
}
}
}
protected void download()
{
int k;
for (k=0; k<this.addresses.Count;k++)
{
FileInfo fileInfo = new FileInfo(addresses[k]);
string name = fileInfo.Name;
if ((name.IndexOf(";") != 0) && (name.IndexOf("=") != 0) && (name.IndexOf("?") != 0) && (name.Length > 0))
{
WebClient client = new WebClient();
string downloadString = client.DownloadString(name);
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DownloadWebFiles
{
public partial class AppDownloadWebFiles : Form
{
public AppDownloadWebFiles()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "Text Files (.txt)|*.txt|All Files (*.*)|*.*";
openFileDialog1.FilterIndex = 1;
WebFiles.CDownloadWebFiles Files = new WebFiles.CDownloadWebFiles;
Files.DownloadWebFiles();
}
private void openFileDialog_FileOk(object sender, CancelEventArgs e)
{
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DownloadWebFiles
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new AppDownloadWebFiles());
}
}
}
Aucun commentaire:
Enregistrer un commentaire