中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档 | 网通镜像
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > Web开发 > Asp > 综合文章
使用递归获取网站下的所有同类型文件
作者:未知 时间:2004-08-19 12:12 出处:Blog 责编:chinaitpower
              摘要:暂无

红色字体就是啦,如有不明白的话,请与我联系QQ:20028205

using System;
using System.Text ;
using System.IO ;
using System.Xml ;
using System.Xml.XPath ;
using System.Web ;
using System.Collections ;


namespace GST.Common.Xml
{
 /// <summary>
 /// 得到站点内的所有Aspx文件,并存入Xml文件中
 /// </summary>
 public class GetAllFiles
 {
  public GetAllFiles()
  {
   //
   // TODO: 在此处添加构造函数逻辑
   //
  }


  /// <summary>
  /// 更新Xml文件的某个支点
  /// </summary>
  /// <param name="Files"></param>
  /// <param name="Desc"></param>
  public void UpdateXmlFile(string Files,string Desc,string FileSrc)
  {
   XmlDocument doc = new XmlDocument();
   doc.Load(HttpContext.Current.Server.MapPath(FileSrc));

   XmlNode Node = doc.SelectSingleNode("/AspxFiles/File[text()=\""+Files+"\"]");

   if (Node!=null)
   {
    Node.Attributes[0].InnerText  = Desc ;
   }

   doc.Save(HttpContext.Current.Server.MapPath(FileSrc));

  }
 
  /// <summary>
  /// 写入Xml文件
  /// </summary>
  public void WriteXmlFile(string FileSrc,ArrayList al)
  {
   XmlDocument doc = new XmlDocument();
   doc.Load(HttpContext.Current.Server.MapPath(FileSrc));
  
   XmlElement Element = doc.DocumentElement ;
      bool Update= false;
   
         

   foreach(object obj in al)
   {
    
   
    XmlNode Node = doc.SelectSingleNode("/AspxFiles/File[text()=\""+obj.ToString()+"\"]");
                 
    if (Node ==null)
    {       
     XmlElement ElementChild =doc.CreateElement("File");
     ElementChild.InnerText = obj.ToString();
     XmlCDataSection cdata = doc.CreateCDataSection(obj.ToString());
     XmlAttribute attribute = doc.CreateAttribute("Desc");
     attribute.Value  =cdata.Value ;
     ElementChild.Attributes.Append(attribute);
     Element.AppendChild(ElementChild);
     Update = true;
    } 

    
    
    
   } 
   if(Update)           
   doc.Save(HttpContext.Current.Server.MapPath(FileSrc));
   
   

 

  }
  /// <summary>
  /// 返回所有的Aspx文件
  /// </summary>
  /// <returns>String Array</returns>
  public void GetAllAspxFile(string WebPath,ref ArrayList al)
  {
           
  
   string[] AspxFiles = Directory.GetDirectories(WebPath);
   
   if (AspxFiles.Length > 0)
   {
    foreach( string AspFile in AspxFiles)
    {   
     
     foreach(string InnerFile in Directory.GetFiles(AspFile))
     {
      if(Path.GetExtension(InnerFile).ToLower() ==".aspx")
      {

       string FileName = Path.GetFileName(InnerFile);
      
       al.Add(FileName);
      }
     }
        
     GetAllAspxFile(AspFile,ref al);
             
    }


  
           
   
   }
  
   else
   {

    string[] Files = Directory.GetFiles(WebPath);
    foreach(string AspFile in Files)
    {
     if(Path.GetExtension(AspFile).ToLower() ==".aspx")
     {

                         string FileName = Path.GetFileName(AspFile);
                          al.Add(FileName);
           
     }
    }
   }
   
   
    
   
  }

 }
}

关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有