Simple .NET script to list all of the .swf files in a folder as XML

Here is some handy code for if you have a bunch of .swf files and you need to get some XML to load them into flash. It should also totally be easy to change the script to list any file type you need enumerated.

<%@ Page ContentType="text/xml" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.IO" %>
<script language="C#" runat="server">
	void Page_Load(object sender, System.EventArgs e) {
		XmlWriter writer = XmlWriter.Create(Response.OutputStream);
		
		writer.WriteStartElement("scenes");
		DirectoryInfo di = new DirectoryInfo(Server.MapPath(""));
		FileInfo[] files = di.GetFiles("*.swf");
		foreach(FileInfo fi in files) {
			
			writer.WriteStartElement("movie");
			writer.WriteAttributeString("name", fi.Name);
			writer.WriteEndElement();
 
		}
		writer.WriteEndElement();
 
		writer.Close();
	}
</script>

This will output something like:

<?xml version="1.0" encoding="utf-8"?>
<scenes>
    <movie name="scene_001.swf"/>
    <movie name="scene_002.swf"/>
    <movie name="scene_003.swf"/>
    <movie name="scene_004.swf"/>
    <movie name="scene_005.swf"/>
    <movie name="scene_006.swf"/>
</scenes>