Display images from directory

Posted on 2013-09-06
Medium Priority
Last Modified: 2013-11-19
I need to display images from the directory. I use datalist and it shows images but it also shows link -Thumbs.db on the page. When I click the link -there is nothing. I do not have this db in my directory. How can I get rid of this Thumbs.db link on the page?
Please, advise

My apsx form:
 <asp:DataList ID="dtlist" runat="server" RepeatColumns="3" CellPadding="5">
<asp:Image Width="100" ID="Image1" ImageUrl='<%# Bind("Name", "~/Images1/{0}") %>' runat="server" />
<br />
<asp:HyperLink ID="HyperLink1" Text='<%# Bind("Name") %>' NavigateUrl='<%# Bind("Name", "~/Images1/{0}") %>' runat="server"/>
<ItemStyle BorderColor="Brown" BorderStyle="dotted" BorderWidth="3px" HorizontalAlign="Center"
VerticalAlign="Bottom" />

My code:

Public Sub BindDataList()

        Dim dir As New DirectoryInfo(MapPath("Images1"))
        Dim files As Array = dir.GetFiles()
        Dim ListItems As New ArrayList
        For Each FileInfo In files
       dtlist.DataSource = ListItems

   End Sub
Question by:msout
1 Comment
LVL 35

Accepted Solution

Robert Schutt earned 2000 total points
ID: 39472107
It's a hidden file created by windows when someone is looking at your server directory directly in thumbnail mode (maybe yourself).

One thing you could do is leave all hidden files out of your list, for example:
        For Each FileInfo As FileInfo In files
            If (FileInfo.Attributes And FileAttributes.Hidden) = 0 Then
            End If

Open in new window

but if it's really just the Thumbs.db you want to eliminate try this instead:
        For Each FileInfo As FileInfo In files
            If Not FileInfo.Name.Equals("thumbs.db", StringComparison.OrdinalIgnoreCase) Then
            End If

Open in new window


Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Magento is the best technology for eCommerce start-ups as it offers the technical expertise and visual appeal to create a store that pulls sales and earns high ROI (Return on investment).
The Super Bowl is just days away. Millions of advertising dollars will be spent in just a few hours to drive people to websites around the globe. Optimizing your site in anticipation of a big event like this (and the traffic surges that follow) will…
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question