Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Dir() problem
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Dir() problem

 Post Reply Post Reply Page  <12
Author
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 29 August 2003 at 8:04am

i just pulled that from some code i did, it was just meant as a guide to some methods to look into, not the actual working code

 

Contribute to the working anarchy we fondly call the Internet
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 29 August 2003 at 8:42am

perhaps this 25 mins of my time can get you started :)
only thing i don't know how to do (and dont have time to investigate) is how to get mulitple types in that "GetFiles" method

<%@ Page Language="VB" %>
<%@ Import Namespace="System"%>
<%@ Import Namespace="System.IO"%>
<%@ Import Namespace="System.Collections"%>
<!--
Stephen Gilboy aka MorningZ
Files in Directory >> DataGrid
-->
<script runat="server">
  Dim sVirtualDir As String = "/images2/" 'Virtual root to images
  Dim blnShowDebugMsg As Boolean = True 'Show the Debug messages

  Sub Page_Load(obj as object, e as eventargs )
 Dim sLocalDir, ThisFileName As String
 sLocalDir = Server.MapPath(sVirtualDir)

 If Not Directory.Exists(sLocalDir) Then
  Message.Text = "Directory """ & sVirtualDir & """ (" & sLocalDir & ") doesn't exist!!"
 Else
  Dim oLocalFile As FileInfo
  Dim aLocalFiles As FileInfo() = (New DirectoryInfo(sLocalDir)).GetFiles("*.gif")

  if aLocalFiles.Length > 0 then  'There are files to get, so continue
   Message.Text = "Total Files in Collection: " & aLocalFiles.Length
   List.DataSource = aLocalFiles
   List.DataBind()
  else
   Message.Text = "No files found"
  end if
 End If
 if blnShowDebugMsg then Message.Visible = True
  End Sub
</script>
<html>
<head>
</head>
<body>
<asp:label id="Message" runat="server" visible="false"/>
<form runat="server">
<asp:Datagrid id="List" runat="server"/>
</form>
</body>
</html>

Contribute to the working anarchy we fondly call the Internet
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 29 August 2003 at 8:43am
btw, not needed in the above:
<%@ Import Namespace="System.Collections"%>
Contribute to the working anarchy we fondly call the Internet
Back to Top
Diep-Vriezer View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 August 2003
Location: Netherlands
Status: Offline
Points: 831
Post Options Post Options   Thanks (0) Thanks(0)   Quote Diep-Vriezer Quote  Post ReplyReply Direct Link To This Post Posted: 29 August 2003 at 11:27am

Wow, Thanks!



Edited by Diep-Vriezer
Gone..
Back to Top
Diep-Vriezer View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 August 2003
Location: Netherlands
Status: Offline
Points: 831
Post Options Post Options   Thanks (0) Thanks(0)   Quote Diep-Vriezer Quote  Post ReplyReply Direct Link To This Post Posted: 29 August 2003 at 12:39pm

It works, thx alot (I edited a little bit, with loop's in it)

Do While aLocalFiles.Length > 0

PicsRepeater.DataSource = aLocalFiles

PicsRepeater.DataBind()

Loop

Gone..
Back to Top
Diep-Vriezer View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 August 2003
Location: Netherlands
Status: Offline
Points: 831
Post Options Post Options   Thanks (0) Thanks(0)   Quote Diep-Vriezer Quote  Post ReplyReply Direct Link To This Post Posted: 29 August 2003 at 12:48pm

 ... Now I recieve the following error:

No default member found for type 'FileInfo'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.MissingMemberException: No default member found for type 'FileInfo'.

Source Error:

Line 131:												<ItemTemplate>
Line 132:													<tr>
Line 133:														<td width="100%" valign="top"><a target="_blank" href="Pics/Images/<%# Container.DataItem("aLocalFiles") %>"><img src="Pics/Thumbs/<%# Container.DataItem("aLocalFiles") %>"></a></td>
Line 134:													</tr>
Line 135:												</ItemTemplate>

Source File: c:\inetpub\wwwroot\sss\Pics\DisplayPics.aspx    Line: 133

Stack Trace:

[MissingMemberException: No default member found for type 'FileInfo'.]
   Microsoft.VisualBasic.CompilerServices.LateBinding.LateIndexGet(Object o, Object[] args, String[] paramnames) +1367
   ASP.DisplayPics_aspx.__DataBind__control4(Object sender, EventArgs e) in c:\inetpub\wwwroot\sss\Pics\DisplayPics.aspx:133
   System.Web.UI.Control.OnDataBinding(EventArgs e) +66
   System.Web.UI.Control.DataBind() +26
   System.Web.UI.Control.DataBind() +86
   System.Web.UI.WebControls.Repeater.CreateItem(Int32 itemIndex, ListItemType itemType, Boolean dataBind, Object dataItem) +127
   System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource) +475
   System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e) +49
   System.Web.UI.WebControls.Repeater.DataBind() +23
   sss.DisplayPics.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\Floris den Heijer\VSWebCache\192.168.1.35\sss\Pics\DisplayPics.aspx.vb:48
   System.Web.UI.Control.OnLoad(EventArgs e) +67
   System.Web.UI.Control.LoadRecursive() +35
   System.Web.UI.Page.ProcessRequestMain() +731

With the code-behind file:

Dim sLocalDir, ThisFileName As String

sLocalDir = Server.MapPath("Images/")

If Not Directory.Exists(sLocalDir) Then

Exit Sub

Else

Dim oLocalFile As FileInfo

Dim aLocalFiles As FileInfo() = (New DirectoryInfo(sLocalDir)).GetFiles("*.jpg")

Do While aLocalFiles.Length > 0

PicsRepeater.DataSource = aLocalFiles

PicsRepeater.DataBind()

Loop

End If

And The ASPX file:

 <asp:Repeater id="PicsRepeater" runat="server"><HeaderTemplate>
 <table width="100%" class="regular" cellpadding="5" cellspacing="0" border="1" bordercolor="#B7B7B7">
 <tr>
 <td width="100%" bgcolor="#D0D0D0"><strong>Foto:</strong></td>
 </tr>
 <tr>
 <td width="100%">&nbsp;</td>
 </tr>
 </HeaderTemplate>
 <ItemTemplate>
 <tr>
 <td width="100%" valign="top"><a target="_blank" href="Pics/Images/<%# Container.DataItem("aLocalFiles") %>"><img src="Pics/Thumbs/<%# Container.DataItem("aLocalFiles") %>"></a></td>
 </tr>
 </ItemTemplate>
 <FooterTemplate>
 </table>
 </FooterTemplate>
 </asp:Repeater>

If you want, you can help me, but I think I can handle this one, it's more like to inform you.

Gone..
Back to Top
 Post Reply Post Reply Page  <12

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.