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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
| private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Veuillez selectionner le repertoire LearningBase situé dans le Spool ");
FolderBrowserDialog ff = new FolderBrowserDialog();
ff.ShowDialog();
textBox1.Text = ff.SelectedPath;
parentDirectory = new DirectoryInfo(textBox1.Text);
DirectoryInfo[] directories = parentDirectory.GetDirectories();
listview.Items.Clear();
listview.Columns.Add("Patron", +50, HorizontalAlignment.Left);
listview.Columns.Add("FolderID",-2, HorizontalAlignment.Left);
foreach (DirectoryInfo directory in directories)
{
string sligne = "";
string nomfolder = parentDirectory + "\\" + directory + "\\" + "\\" + "folderID.txt";
StreamReader rec = new StreamReader(nomfolder);
ArrayList arrText = new ArrayList();
while (sligne != null)
{
sligne = rec.ReadLine();
if (sligne != null)
arrText.Add(sligne);
}
rec.Close();
foreach (string sortie in arrText)
{
ListViewItem lvi = new ListViewItem(new string[] { directory.ToString(), sortie });
listview.Items.Add(lvi);
}
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
String destination;
private void listview_SelectedIndexChanged(object sender, EventArgs e)
{
if (listview.SelectedItems.Count > 0 && listview.SelectedItems.Count < 2)
{
string filename;
string result;
String destination = listview.SelectedItems[0].Text;
String nomfolder = parentDirectory + "\\" + destination;
string[] ajoutlistpat = Directory.GetFiles(nomfolder);
for (int i = 0; i < ajoutlistpat.Length; i++)
{
filename = ajoutlistpat[i];
result = Path.GetFileName(filename);
if (result != "folderID.txt")
{
listepat.Items.Add(result);
}
}
}
}
private void listepat_SelectedIndexChanged(object sender, EventArgs e)
{
destination = listview.SelectedItems[0].Text;
String myPath2 = parentDirectory + "\\" + destination;//On concave 2 chaines
string Folder = listepat.SelectedItem.ToString();
string sligne = "";
String myPath3 = myPath2 + "\\" + Folder;
int cpt = 0;
int cpt1 = 0;
int cpt2 = 0;
int cpt3 = 0;
try
{
if (listepat.SelectedItem.ToString() == "folderID.txt")
{
StreamReader rec = new StreamReader(myPath3);
ArrayList arrText = new ArrayList();
while (sligne != null)
{
sligne = rec.ReadLine();
if (sligne != null)
arrText.Add(sligne);
}
rec.Close();
}
else
{
{
XmlTextReader lecteur1 = new XmlTextReader(myPath3);
XmlDocument doc1 = new XmlDocument();
doc1.Load(lecteur1);
int nbElementMono1 = doc1.GetElementsByTagName("ElementExtractorMono.3").Count;
int nbElementWord1 = doc1.GetElementsByTagName("ElementIdentificatorWord.6").Count;
Console.ReadLine();
textBox3.Text = "ElementExtractorMono :" + nbElementMono1.ToString() + " " + "ElementIdentificatorWord :" + nbElementWord1.ToString();
}
}
}
catch (Exception ex)
{
MessageBox.Show("erreur");
}
} |
Partager