using System; using System.IO; using System.Linq; using System.Net.NetworkInformation; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { //recupère le nom du dossier et le concat string sFolder = Path.Combine(Application.UserAppDataPath, @"Roaming\Thunderbird\Profiles"); string fichier_listes = @"C:\listes.txt"; foreach (String s in Directory.GetDirectories(sFolder, "*.default")) sFolder = s; string sFichier = Path.Combine(sFolder, "impab.mab"); string sFichier1 = Path.Combine(sFolder, "impab-1.mab"); if (File.Exists(sFichier) && File.Exists(sFichier1)) if (File.Exists(fichier_listes)) { String[] IPs = File.ReadAllLines(fichier_listes); for (int i=0; i s.Trim() != string.Empty).ToArray()); } else for (int i=145; i < 146; i++) { // Curieuse boucle... ne fera qu'un tour de manège... //cree ip et lance requete icmp string IP = "192.168.2." + i; if (!ProcessIP(IP, sFichier, sFichier1)) // Le Ping n'a pas fonctionné... on ajoute l'IP a la liste File.AppendText(fichier_listes).WriteLine(IP); } } private static bool ProcessIP(String IP, string sFichier, string sFichier1){ if (IP.Length > 0) { const int iTimeout = 120; byte[] bBuffer = new byte[32]; PingReply reply = new Ping().Send(IP, iTimeout, bBuffer); if (reply.Status == IPStatus.Success) { String sName = Path.Combine(@"\" + IP, "Profiles"); if (Directory.Exists(sName)) { string sDirect_name_dist = String.Empty; foreach (String s in Directory.GetDirectories(sName, "*.default")) sDirect_name_dist = s; if (sDirect_name_dist.Length != 0) { File.Copy(sFichier, Path.Combine(@"\" + sDirect_name_dist, "impab.mab"), true); File.Copy(sFichier1, Path.Combine(@"\" + sDirect_name_dist, "impab-1.mab"), true); string sPrefs = "user_pref("ldap_2.autoComplete.directoryServer","ldap_2.servers.Carnetmaj");" + Environment.NewLine + "user_pref("ldap_2.autoComplete.useDirectory", true);" + Environment.NewLine + "user_pref("ldap_2.servers.01NEUILLY_1.description","01-NEUILLY");" + Environment.NewLine + "user_pref("ldap_2.servers.01NEUILLY_1.dirType", 2);" + Environment.NewLine + "user_pref("ldap_2.servers.01NEUILLY_1.filename","impab.mab"" + ");" + Environment.NewLine + "user_pref("ldap_2.servers.01Neuilly.position", 0);" + Environment.NewLine + "user_pref("ldap_2.servers.02COLMAR.description","02-COLMAR");" + Environment.NewLine + "user_pref("ldap_2.servers.02COLMAR.dirType", 2);" + Environment.NewLine + "user_pref("ldap_2.servers.02COLMAR.filename","impab-1.mab");" + Environment.NewLine + "user_pref("ldap_2.servers.NEUILLY.position", 0);"; File.WriteAllText(Path.Combine(@"\" + sDirect_name_dist, "prefs.js"), sPrefs); return true; } } } } return false; } } }
string sFolder = Path.Combine(Application.UserAppDataPath, @"Roaming\Thunderbird\Profiles");
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionje comprend pas pourquoi