我网站有一个目录Main里面有一个index.html然后根目录也有一个index.html
我想用代码修改Main里面的index.html然后用这个文件替换根目录的index.html着急着急!!!!
我想用代码修改Main里面的index.html然后用这个文件替换根目录的index.html着急着急!!!!
解决方案 »
- 正则小问题
- ▲▲▲请问,这样的数据网格控件时什么控件??▲▲▲
- 如何写一个js让它每各1秒的去检查一个客户端object对象的某个属性.
- 定期触发某种事件的程序是怎么做的,如每天发信....
- 类中的全局变量问题~~ 为什么在一个函数中给全局变量赋了值,在另个函数里引用却为空呢???
- 关于URL传参数的问题:
- 当鼠标经过图片的时候,怎么才能使相应出现的工具兰屏蔽掉?
- 关于在Updatapanel中下拉框闪烁的问题?
- c# 怎么让两张图片叠加啊?
- CS0016: 未能写入输出文件...,是什么原因?
- .net代码中关于WPS样式设置的问题..
- 简单问题:CreateUserWizard控件使用 自定义创建用户步骤,如何访问自己加进去的控件
ZipOutputStream zos = null;
String strBaseDir = "";
protected void Button3_Click(object sender, EventArgs e)
{
dlZipDir(Server.MapPath("test"), "解压到网站根目录下");
}
private void dlZipDir(string strPath, string strFileName)
{
MemoryStream ms = null;
Response.ContentType = "application/octet-stream";
strFileName = HttpUtility.UrlEncode(strFileName).Replace('+', ' ');
Response.AddHeader("Content-Disposition", "attachment; filename=" + strFileName + ".zip");
ms = new MemoryStream();
zos = new ZipOutputStream(ms);
strBaseDir = strPath + "\\";
addZipEntry(strBaseDir);
zos.Finish();
zos.Close();
Response.Clear();
Response.BinaryWrite(ms.ToArray());
Response.End();
}
private void addZipEntry(string PathStr)
{
byte[] buffer;
string strEntryName;
string WebUrl = Request.Url.DnsSafeHost;
WebUrl = WebUrl.Substring(WebUrl.IndexOf(".", 0) + 1);
ZipEntry entry;
DirectoryInfo di = new DirectoryInfo(PathStr);
foreach (DirectoryInfo item in di.GetDirectories())
{
addZipEntry(item.FullName);
}
foreach (FileInfo item in di.GetFiles())
{
if (item.ToString() == "index1.htm" || item.ToString() == "258a.htm")
{
StreamReader sr = new StreamReader(item.FullName, Encoding.GetEncoding("gb2312"));
StringBuilder line = new StringBuilder(sr.ReadToEnd());
sr.Close();
line.Replace("tihuan", "<a>qqqqqqqqqqqqqqqqqqqqqq</a>");
//line.Replace("domainsite", "." + WebUrl);
buffer = Encoding.GetEncoding("gb2312").GetBytes(line.ToString());
strEntryName = item.FullName.Replace(strBaseDir, "");
entry = new ZipEntry("../" + strEntryName);
zos.PutNextEntry(entry);
zos.Write(buffer, 0, buffer.Length);
}
}
zos.Dispose();
zos.Close();
}
}
这是下载代码 我看不明白 。 就是把这文件改完了然后保存下载 我不想下载 我想让他替换根目录的index.html 着急
保存路径就是根目录..
直接把改好的文件覆盖下index.html不就完了?
我想给客户一个小的管理页面 让他可以随时更改他的联系方式等。 总不能让客户打打开html页更改啊
具体代码应该怎么写??? 菜鸟
多调试几次看看
例如: <td>楼主</td> 改成 <td>@$8848_Name$@</td>
总之就是极低可能会和其他文本重复的字符串第二步:制作添加页面.就跟注册一样..
读取main\index.html的内容,然后字符串替换. 一个一个的把用户输入的内容替换到对应的约定变量里
第三步:把替换好的字符串保存为根目录下的index.html覆盖
StringBuilder line = new StringBuilder(sr.ReadToEnd());
sr.Close();
line.Replace("tihuan", "<a>qqqqqqqqqqqqqqqqqqqqqq</a>");
//替换部分==================================================================
StreamWriter sw=new StreamWriter("C:web\\index.html",false,Encoding.GetEncoding("gb2312"));
sw.Write(line.ToString());
sw.Flush();
sw.Close();