asp如何生成html静态网页
我对asp一点也不懂请直接写完整的源码asp生成静态网页怎么说呢把html模版生成静态网页........生成内容(这里是html模版)把整个文件生成为html生成路径....
我对asp一点也不懂 请直接写完整的源码
asp生成静态网页
怎么说呢 把html模版生成 静态网页
........ 生成内容(这里是html模版)把整个文件生成为html
生成路径......
生成名字(生成出来的文件名最好是取当前时间)
求大神写源码 展开
asp生成静态网页
怎么说呢 把html模版生成 静态网页
........ 生成内容(这里是html模版)把整个文件生成为html
生成路径......
生成名字(生成出来的文件名最好是取当前时间)
求大神写源码 展开
1个回答
展开全部
public class WriteFile
{
public WriteFile()
{
}
public static bool createHtml(string[] strnewsHtml,string[] stroldHtml,string strModeFilePath,string strPath)
{
bool flag = false;
StreamReader sr = null;
StreamWriter sw = null;
string filepath = HttpContext.Current.Server.MapPath(strModeFilePath);
Encoding code = Encoding.GetEncoding("gb2312");
string s = string.Empty;
try
{
sr = new StreamReader(filepath,code);
s = sr.ReadToEnd();
}
catch (Exception ex)
{
throw ex;
}
finally
{
sr.Close();
}
try
{
for (int i = 0; i < strnewsHtml.Length; i++)
{
s = s.Replace(stroldHtml[i], strnewsHtml[i]);
}
sw = new StreamWriter(HttpContext.Current.Server.MapPath(strPath), false, code);
sw.Write(s);
flag = true;
}
catch (Exception ex)
{
flag = false;
throw ex;
}
finally
{
sw.Flush();
sw.Close();
}
return flag;
}
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;
}
}
{
public WriteFile()
{
}
public static bool createHtml(string[] strnewsHtml,string[] stroldHtml,string strModeFilePath,string strPath)
{
bool flag = false;
StreamReader sr = null;
StreamWriter sw = null;
string filepath = HttpContext.Current.Server.MapPath(strModeFilePath);
Encoding code = Encoding.GetEncoding("gb2312");
string s = string.Empty;
try
{
sr = new StreamReader(filepath,code);
s = sr.ReadToEnd();
}
catch (Exception ex)
{
throw ex;
}
finally
{
sr.Close();
}
try
{
for (int i = 0; i < strnewsHtml.Length; i++)
{
s = s.Replace(stroldHtml[i], strnewsHtml[i]);
}
sw = new StreamWriter(HttpContext.Current.Server.MapPath(strPath), false, code);
sw.Write(s);
flag = true;
}
catch (Exception ex)
{
flag = false;
throw ex;
}
finally
{
sw.Flush();
sw.Close();
}
return flag;
}
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;
}
}
追问
不可以用, 也找不到生成路径
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询