| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 687 人关注过本帖
标题:帮忙解释下这段代码吧
取消只看楼主 加入收藏
belong0204
Rank: 2
等 级:论坛游民
帖 子:66
专家分:30
注 册:2009-4-9
结帖率:73.33%
收藏
已结贴  问题点数:20 回复次数:1 
帮忙解释下这段代码吧
看了半天,看不懂,各位大哥帮忙解释下吧,谢谢了。

public class Files
{
    public Files()
    {
        //
        // TODO: 在此处添加构造函数逻辑
        //
    }
    public static bool CreatHtmlPage(string[] strNewsHtml, string[] strOldHtml, string strModeFilePath, string strPageFilePath)
    {
        bool Flage = false;
        StreamReader ReaderFile = null;
        StreamWriter WrirteFile = null;
        string FilePath = HttpContext.Current.Server.MapPath(strModeFilePath);
        Encoding Code = Encoding.GetEncoding("gb2312");
        string strFile = string.Empty;
        try
        {
            ReaderFile = new StreamReader(FilePath, Code);
            strFile = ReaderFile.ReadToEnd();

        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            ReaderFile.Close();
        }
        try
        {
            int intLengTh = strNewsHtml.Length;
            for (int i = 0; i < intLengTh; i++)
            {
                strFile = strFile.Replace(strOldHtml[i], strNewsHtml[i]);
            }
            WrirteFile = new StreamWriter(HttpContext.Current.Server.MapPath(strPageFilePath), false, Code);
            WrirteFile.Write(strFile);
            Flage = true;
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {

            WrirteFile.Flush();
            WrirteFile.Close();
        }
        return Flage;
    }
    public static bool UpdateHtmlPage(string[] strNewsHtml, string[] strStartHtml, string[] strEndHtml, string strHtml)
    {
        bool Flage = false;
        StreamReader ReaderFile = null;
        StreamWriter WrirteFile = null;
        string FilePath = HttpContext.Current.Server.MapPath(strHtml);
        Encoding Code = Encoding.GetEncoding("gb2312");
        string strFile = string.Empty;
        try
        {
            ReaderFile = new StreamReader(FilePath, Code);
            strFile = ReaderFile.ReadToEnd();

        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            ReaderFile.Close();
        }
        try
        {
            int intLengTh = strNewsHtml.Length;
            for (int i = 0; i < intLengTh; i++)
            {
                int intStart = strFile.IndexOf(strStartHtml[i]) + strStartHtml[i].Length;
                int intEnd = strFile.IndexOf(strEndHtml[i]);
                string strOldHtml = strFile.Substring(intStart, intEnd - intStart);
                strFile = strFile.Replace(strOldHtml, strNewsHtml[i]);
            }
            WrirteFile = new StreamWriter(FilePath, false, Code);
            WrirteFile.Write(strFile);
            Flage = true;
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {

            WrirteFile.Flush();
            WrirteFile.Close();
        }
        return Flage;
    }
}
搜索更多相关主题的帖子: 解释 代码 
2010-02-01 15:55
belong0204
Rank: 2
等 级:论坛游民
帖 子:66
专家分:30
注 册:2009-4-9
收藏
得分:0 
方法中传递的参数是怎么来的啊。
2010-02-04 08:36
快速回复:帮忙解释下这段代码吧
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012521 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved