foreach(string file in strAllFiles)
{
foreach(char c in file)
{
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 i = file.IndexOf(c);
file1 = file.Remove(i, 1);
file2 = file1.Insert(i, o.ToString());
file = file2;
}
}
}
}
In the last line file=file2
, I am getting the error:
cannot assign to file because it is a foreach iteration variable