File: FileList.ascx

package info (click to toggle)
xsp 3.8-2.1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,352 kB
  • ctags: 2,452
  • sloc: cs: 13,500; sh: 12,512; xml: 8,279; perl: 1,189; makefile: 765; ansic: 299; php: 6
file content (30 lines) | stat: -rw-r--r-- 1,033 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<%@ Control Language="C#" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Text" %>
<%
   ArrayList dirs = new ArrayList ();
   ArrayList files = new ArrayList ();
   string physPath = Path.GetDirectoryName (Request.PhysicalPath);
   DirectoryInfo dir = new DirectoryInfo (physPath);
   
   foreach (string d in Directory.GetDirectories (physPath))
          dirs.Add (d);
   foreach (string f in Directory.GetFiles (physPath)) {
          if (f == "index.aspx" || f == "default.aspx")
                 continue;

          files.Add (f);
   }

   StringBuilder sb = new StringBuilder ("<ul class=\"dirlist\">");
   dirs.Sort ();
   foreach (string d in dirs)
          sb.AppendFormat ("<li><a href=\"{0}\" class=\"indexDirectory\">{0}</a></li>", Path.GetFileName (d));
  
   files.Sort ();
   foreach (string f in files)
          sb.AppendFormat ("<li><a href=\"{0}\" class=\"indexFile\">{0}</a></li>", Path.GetFileName (f));

   Response.Write (sb.ToString ());
%>