[AccessD] Classes

Mwp.Reid at Queens-Belfast.AC.UK Mwp.Reid at Queens-Belfast.AC.UK
Sun Jun 29 08:57:07 CDT 2003


John or anyone (<:


Can you define a static class? The following is  a bit of C Sharp. Directory is 
termed a static class as it is not destroyed when the code stops. For info the 
full code is below.

      public string FileName;   
      void Page_Load(Object sender, EventArgs e) {
         if (!IsPostBack) 
         {
            //set directory and array
            Directory myDirectory;
            ArrayList values = new ArrayList();
            //get files
            String [] files = Directory.GetFiles("C:\\Inetpub\\wwwroot\\","*");

Martin


<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.IO" %>
<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<html>
<head>
<title>Tables</title>
<meta http-equiv="Content-Type" 
content="text/html; charset=iso-8859-1">
<script language="C#" runat="server">        
      //create a string to hold the current file name
      public string FileName;   
      void Page_Load(Object sender, EventArgs e) {
         if (!IsPostBack) 
         {
            //set directory and array
            Directory myDirectory;
            ArrayList values = new ArrayList();
            //get files
            String [] files = Directory.GetFiles("C:\\Inetpub\\wwwroot\\","*");
 //iterate through list, replace path info, 
//and add to the listbox with the Add method.
            for(int i=0;i<files.Length;i++){
            FileName = files[i];
            values.Add (FileName);
                  TableRow rw = new TableRow();
                  TableCell cText = new TableCell();
                  Label lbl = new Label();
                  lbl.Text = FileName;
                  cText.Controls.Add(lbl);
                  rw.Cells.Add(cText);
                  table.Rows.Add(rw);
                  }
         }
      }
        </script>
</head>
<body>
<asp:Table BorderColor="#CCCCCC" BorderStyle="dashed" BorderWidth="1" Font-
Name="Verdana" Font-Size="10" HorizontalAlign="Left" ID="table" runat="server" 
Width="300"><asp:TableRow ID="tRow" runat="server"><asp:TableHeaderCell 
ID="tHeader1" runat="server" Text="File 
Name"></asp:TableHeaderCell></asp:TableRow></asp:Table>

</body>
</html>


More information about the AccessD mailing list