Ejemplo n.º 1
0
        public void repalcePar(string configName, string targetFolder)
        {
            setXml        xml        = new setXml();
            List <parset> pars       = setXml.getPars(configName);
            DataTable     dtFile     = xml.readXMLCopyPath();
            DirectoryInfo TempFolder = new DirectoryInfo(targetFolder);

            for (int i = 0; i < dtFile.Rows.Count; i++)
            {
                string   path = TempFolder.FullName + "\\" + dtFile.Rows[i]["projectname"].ToString() + "\\" + dtFile.Rows[i]["configFolder"].ToString() + "" + dtFile.Rows[i]["filepath"].ToString();
                FileInfo file = new FileInfo(path);

                Encoding encoding;
                encoding = GetFileEncodeType(file.FullName);

                FileStream   fs = new FileStream(path, FileMode.Open, FileAccess.ReadWrite);
                StreamReader sr;


                sr = new StreamReader(fs, encoding);
                string con = sr.ReadToEnd();
                foreach (parset par in pars)
                {
                    con = con.Replace("{$" + par.id + "." + par.key + "}", par.value);
                }
                sr.Close();
                fs.Close();
                File.WriteAllText(path, con, encoding);
            }
        }
Ejemplo n.º 2
0
        private void applyConfig(string targetFolder, List <string[]> checkapp)
        {
            setXml    xml    = new setXml();
            DataTable dtFile = xml.readXMLCopyPath();

            foreach (string [] configFolder in checkapp)
            {
                DataTable selectDT = new DataTable();
                selectDT = dtFile.Clone();
                System.Data.DataRow[] selectDT_row = dtFile.Select("configFolder='" + configFolder[0] + "'");
                for (int j = 0; j < selectDT_row.Length; j++)
                {
                    selectDT.ImportRow((System.Data.DataRow)selectDT_row[j]);
                }

                for (int i = 0; i < selectDT.Rows.Count; i++)
                {
                    string oriFilePath    = targetFolder + "\\" + selectDT.Rows[i]["projectname"].ToString() + "\\" + selectDT.Rows[i]["configFolder"].ToString() + selectDT.Rows[i]["filepath"].ToString();
                    string targetFilePath = configFolder[1] + selectDT.Rows[i]["filepath"].ToString();
                    if (File.Exists(targetFilePath))
                    {
                        File.Delete(targetFilePath);
                    }
                    File.Copy(oriFilePath, targetFilePath);
                }
            }
        }