static string CS = ConfigurationManager.ConnectionStrings["Constring"].ConnectionString.ToString(); static void Main(string[] args) { string date = DateTime.Today.ToString("yyyyMMdd"); string date2=DateTime.Today.ToString("YYYYMMMDD"); string dirPath = string quarintine = string filepattern1 = "LS_PRSADT_*.txt"; string backupfile = Path.Combine(quarintine, date); string movefiles = Path.Combine(quarintine, date2); string[] filesDT = Directory.GetFiles(dirPath, filepattern1); string s1 = null; string s2 = null; Directory.CreateDirectory(backupfile); filesDT.ToList().ForEach(k => File.Copy(k, Path.Combine(backupfile, Path.GetFileName(k)))); for (int i = 0; i < filesDT.Length; i++) { string file = filesDT[i]; FileInfo fileinfo = new FileInfo(file); string content = File.ReadAllText(fileinfo.FullName); foreach (char c in content) { if (c > 127) { using (SqlConnection con = new SqlConnection(CS)) { con.Open(); SqlCommand sqlcom = new SqlCommand("sp_ReplaceNonAsciiCharset", con); sqlcom.CommandType = CommandType.StoredProcedure; SqlParameter sqlparam = new SqlParameter(); sqlparam.ParameterName = "@non_ascii_char"; sqlparam.Direction = ParameterDirection.Input; sqlparam.SqlDbType = SqlDbType.NChar; sqlparam.Size = 2; sqlparam.Value = c; sqlcom.Parameters.Add(sqlparam); object o = sqlcom.ExecuteScalar(); int j = content.IndexOf(c); s1 = content.Remove(j, 1); s2 = s1.Insert(i, o.ToString()); content = s2; } } } filesDT[i] = content;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)