public void GenAndUpload() { try { //DirectoryInfo dsource = new DirectoryInfo(CTLConfig._pathfilelocal); //code cu GenFrom file txt //foreach(FileInfo f in dsource.GetFiles("*.txt")) //{ // //set ID APP // SetValueFile(f.FullName); // //set ads // SetTrueFalseAD(f.FullName); // FTPHelper ftphelper = new FTPHelper(CTLConfig._user, CTLConfig._pass, CTLConfig._pathftp); // ftphelper.UploadFile(f.FullName); //} //end //code moi genfromfile xml FileInfo filegenxml = new FileInfo(Path.Combine(Application.StartupPath, "ConfigADS.xml")); if (filegenxml.Exists) { XmlDocument doc = new XmlDocument(); doc.Load(Application.StartupPath + @"\ConfigADS.xml"); XmlNode nodeList = doc.SelectSingleNode("/GenADS"); if (nodeList != null) { foreach (XmlNode node in nodeList.ChildNodes) { string[] OnAds = node.Attributes["OnAds"].Value.Split(','); string[] RanAds = node.Attributes["RanAds"].Value.Split(','); FileInfo fileUpload = new FileInfo(Path.Combine(CTLConfig._pathfilelocal, node.Name + ".txt")); if (!fileUpload.Exists) { continue; } entyconfigfile enty = new entyconfigfile(fileUpload.FullName); enty.loadValuFromFile(); enty.SetFalseALLAd(); foreach (string str in OnAds) { enty.SetvalueKey(str, "true"); } Random ran = new Random(); foreach (string str in RanAds) { enty.SetvalueKey(str, ran.Next(0, 3) > 0 ? "true" : "false"); } FTPHelper ftphelper = new FTPHelper(CTLConfig._user, CTLConfig._pass, CTLConfig._pathftp); ftphelper.UploadFile(fileUpload.FullName); } } } else { CTLError.WriteError("KO ton tai file ConfigADS.xml ", "Loi gen ads"); } } catch (Exception ex) { CTLError.WriteError("loi GenAndUpload ", ex.Message); MessageBox.Show("Loi " + ex.Message); } }