Recursive red font is, if you do not understand, please contact me 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>
///gets all the ASPX files in the site and stores them in an XML file
///</summary>
public class Getallfiles
{
public getallfiles ()
{
//
//TODO: Add constructor logic here
//
}
///<summary>
///Update a fulcrum of an XML file
///</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>
///write to XML file
///</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>
///returns all ASPX files
///</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);
}
}
}
}
}
}