Mwp.Reid at Queens-Belfast.AC.UK
Mwp.Reid at Queens-Belfast.AC.UK
Sun Jun 29 09:29:57 CDT 2003
Thanks John That sounds resonable in this case as you dont instatiate the directory. Martin Quoting John Colby <jcolby at colbyconsulting.com>: > Martin, > > I'm not the expert in this but my take is that a static class is one > that > you don't have to instantiate in order to use it's methods. If I had > to > guess, I'd say there is already an instance that the framework > instantiates, > and you are using it's methods. > > John W. Colby > www.colbyconsulting.com > > -----Original Message----- > From: accessd-bounces at databaseadvisors.com > [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of > Mwp.Reid at Queens-Belfast.AC.UK > Sent: Sunday, June 29, 2003 9:57 AM > To: accessd at databaseadvisors.com > Subject: [AccessD] Classes > > > 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> > _______________________________________________ > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > > > > _______________________________________________ > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com >