把asp.net下文件夹VIEW中的所有文件页面中的字符串aaa替换成bbb

解决方案 »

  1.   

    点"编辑/查找喝替换/在文件中替换/" 
    在弹出对话框设置"查找范围"为整个解决方案!! 
    =====================================要慎重,这个可不好Ctrl+Z 。
      

  2.   

    useing System.IO.Stream;
    用stream流读取文件内容存到字符串变量 str 中  在用Relace()替换字符串中的字符这个应该会吧
    当然 如果需要修改文件内容的话还是stream操作
    StreamReader 读取
    StreamWriter 写入
      

  3.   

    这个是我一个网站的部分代码 看下吧  建议熟悉下stream类
    string path = HttpContext.Current.Server.MapPath("~/");
            Encoding code = Encoding.GetEncoding("gb2312");
            // 读取模板文件
            string temp = HttpContext.Current.Server.MapPath("~/TemplateHtml/indexTemplate.html");
            StreamReader sr = null;
            StreamWriter sw = null;
            string str = "";
            try
            {
                sr = new StreamReader(temp, code);
                str = sr.ReadToEnd(); // 读取文件
            }
            catch (Exception exp)
            {
                HttpContext.Current.Response.Write(exp.Message);
                HttpContext.Current.Response.End();
                sr.Close();
            }
            finally
            {
                sr.Close();
            }