Professional Web Applications Themes

how to check if file extension is member of filter list? - ASP

Hello, I am developping a file browser bu use of internet explorer. I am already so far that I get a full list of all the files of a selected directory. However, I only want to display certain files, i.e. pictures: jpg, gif, png, tiff, etc... So I want to set up a main variable, containing this "filter" Now for every listed file, I want to check if its extension is listed in the filter. How can I achieve this without having an if-then for every extension? tia bartp -- ========================================== Hyper A.R.T. bart plessers Paul Van Ostaijenlaan 4 3001 ...

  1. #1

    Default how to check if file extension is member of filter list?

    Hello,

    I am developping a file browser bu use of internet explorer.

    I am already so far that I get a full list of all the files of a selected
    directory.
    However, I only want to display certain files, i.e. pictures: jpg, gif, png,
    tiff, etc...

    So I want to set up a main variable, containing this "filter"

    Now for every listed file, I want to check if its extension is listed in the
    filter.

    How can I achieve this without having an if-then for every extension?


    tia

    bartp




    --

    ==========================================
    Hyper A.R.T.
    bart plessers
    Paul Van Ostaijenlaan 4
    3001 Heverlee
    BELGIUM
    tel: +32 (16) 23.40.85
    fax: +32 (16) 23.41.06
    ==========================================






    bart plessers Guest

  2. #2

    Default Re: how to check if file extension is member of filter list?

    Yan,

    that was what I was looking for!

    will try it tomorrow. Maybe you can provide me with some sytax? How to build
    the list? Is it just a string with all my extensions, separated by "," or
    should I define some table?

    tia

    bartp

    --

    ==========================================
    Hyper A.R.T.
    bart plessers
    Paul Van Ostaijenlaan 4
    3001 Heverlee
    BELGIUM
    tel: +32 (16) 23.40.85
    fax: +32 (16) 23.41.06
    ==========================================





    "yan Roosens" <yan.roosensskynet.be> wrote in message
    news:3F245F43.918AE344skynet.be...
    > Hello Bart,
    >
    > bart plessers wrote:
    >
    > > Hello,
    > >
    > > I am developping a file browser bu use of internet explorer.
    > >
    > > I am already so far that I get a full list of all the files of a
    selected
    > > directory.
    > > However, I only want to display certain files, i.e. pictures: jpg, gif,
    png,
    > > tiff, etc...
    > >
    > > So I want to set up a main variable, containing this "filter"
    > >
    > > Now for every listed file, I want to check if its extension is listed in
    the
    > > filter.
    > >
    > > How can I achieve this without having an if-then for every extension?
    >
    > You could build a list of the extensions you want to display, with a
    separator
    > (a comma should do the trick) and use Instr(the list, the file extension)
    >
    > Yan
    >
    >
    >
    >

    bart plessers Guest

  3. #3

    Default Re: how to check if file extension is member of filter list?


    "bart plessers" <bartplessershotmail.com> wrote in message
    news:e0Ktg19UDHA.2360TK2MSFTNGP10.phx.gbl...
    > Hello,
    >
    > I am developping a file browser bu use of internet explorer.
    >
    > I am already so far that I get a full list of all the files of a selected
    > directory.
    > However, I only want to display certain files, i.e. pictures: jpg, gif, png,
    > tiff, etc...
    >
    > So I want to set up a main variable, containing this "filter"
    >
    > Now for every listed file, I want to check if its extension is listed in the
    > filter.
    >
    > How can I achieve this without having an if-then for every extension?
    >

    Hi,
    here is my preferred method:


    '-------------------------------------------

    AllowedExtensions = Array("asp", "csv", "doc", "htm")


    For i = 0 To UBound(FileList)
    If IsFileNameOK(FileList(i)) Then ' your code here
    Next


    Function IsFileNameOK(strFileSpec) 'Boolean
    ' Find the dot
    DotPos = InStrRev(strFileSpec, ".")
    If DotPos > 0 Then
    ' get the extension
    strExtension = LCase(Right(strFileSpec, Len(strFileSpec) - DotPos))
    ' Loop through allowable extensions
    For i = 0 To UBound(AllowedExtensions)
    ' Check for a match
    If strExtension = LCase(AllowedExtensions(i)) Then
    IsFileNameOK = True
    Exit For
    End If
    Next ' i
    End If ' dot found
    End Function


    Tia Guest

  4. #4

    Default Re: how to check if file extension is member of filter list?

    On Mon, 28 Jul 2003 01:39:31 +0200, "bart plessers"
    <bartplessershotmail.com> wrote:
    >Yan,
    >
    >that was what I was looking for!
    >
    >will try it tomorrow. Maybe you can provide me with some sytax? How to build
    >the list? Is it just a string with all my extensions, separated by "," or
    >should I define some table?
    >
    >tia
    >
    >bartp
    here's something I whipped up. You should be able to modify it as
    necessary.

    function strDir(strPath)
    Dim fil,fol,arrExt,FSO,intCtr,strOut
    Set FSO = server.createobject("Scripting.FileSystemObject")
    arrExt = Array("gif", "jpg", "tif") ' put your extensions in here
    Set fol = FSO.GetFolder(strDir)
    strOut = vbNullString
    For Each fil In fol.Files
    For intCtr = LBound(arrExt) To UBound(arrExt)
    If StrComp(Mid(fil.ShortName, InStrRev(fil.ShortName, ".")
    + 1), arrExt(intCtr), 1) = 0 Then
    strOut = strOut & fil.Path & "<br>"
    End If
    Next
    Next
    set FSO=nothing
    strDir=strOut
    end function
    %>

    <html>
    <body>
    <p><%=strDir("c:\pictures")%></p>
    </body>
    </html>


    the function will return a string with <br> between the files. Of
    course, you can put whatever you want in there for syntax, like
    "<tr><td>" to return a HTML table, etc.

    Dan Bush
    [email]meR3M0V3.danbush.com[/email]

    Daniel Bush Guest

  5. #5

    Default Re: how to check if file extension is member of filter list?

    thanx for code and your time!
    Tomorrow I'll be on holliday, but surely give it a try afterwards!

    bartp

    --

    ==========================================
    Hyper A.R.T.
    bart plessers
    Paul Van Ostaijenlaan 4
    3001 Heverlee
    BELGIUM
    tel: +32 (16) 23.40.85
    fax: +32 (16) 23.41.06
    ==========================================





    "Tia" <notany.address> wrote in message
    news:bg1pt1$e0h$1sparta.btinternet.com...
    >
    > "bart plessers" <bartplessershotmail.com> wrote in message
    > news:e0Ktg19UDHA.2360TK2MSFTNGP10.phx.gbl...
    > > Hello,
    > >
    > > I am developping a file browser bu use of internet explorer.
    > >
    > > I am already so far that I get a full list of all the files of a
    selected
    > > directory.
    > > However, I only want to display certain files, i.e. pictures: jpg, gif,
    png,
    > > tiff, etc...
    > >
    > > So I want to set up a main variable, containing this "filter"
    > >
    > > Now for every listed file, I want to check if its extension is listed in
    the
    > > filter.
    > >
    > > How can I achieve this without having an if-then for every extension?
    > >
    >
    >
    > Hi,
    > here is my preferred method:
    >
    >
    > '-------------------------------------------
    >
    > AllowedExtensions = Array("asp", "csv", "doc", "htm")
    >
    >
    > For i = 0 To UBound(FileList)
    > If IsFileNameOK(FileList(i)) Then ' your code here
    > Next
    >
    >
    > Function IsFileNameOK(strFileSpec) 'Boolean
    > ' Find the dot
    > DotPos = InStrRev(strFileSpec, ".")
    > If DotPos > 0 Then
    > ' get the extension
    > strExtension = LCase(Right(strFileSpec, Len(strFileSpec) - DotPos))
    > ' Loop through allowable extensions
    > For i = 0 To UBound(AllowedExtensions)
    > ' Check for a match
    > If strExtension = LCase(AllowedExtensions(i)) Then
    > IsFileNameOK = True
    > Exit For
    > End If
    > Next ' i
    > End If ' dot found
    > End Function
    >
    >

    bart plessers Guest

  6. #6

    Default Re: how to check if file extension is member of filter list?

    thanx for code and your time!
    Tomorrow I'll be on holliday, but surely give it a try afterwards!

    bartp

    --

    ==========================================
    Hyper A.R.T.
    bart plessers
    Paul Van Ostaijenlaan 4
    3001 Heverlee
    BELGIUM
    tel: +32 (16) 23.40.85
    fax: +32 (16) 23.41.06
    ==========================================





    "Daniel Bush" <meR3MOV3.danbush.com> wrote in message
    news:nnh9iv81bt80qjifer4m8uq79l762qtl424ax.com...
    > On Mon, 28 Jul 2003 01:39:31 +0200, "bart plessers"
    > <bartplessershotmail.com> wrote:
    >
    > >Yan,
    > >
    > >that was what I was looking for!
    > >
    > >will try it tomorrow. Maybe you can provide me with some sytax? How to
    build
    > >the list? Is it just a string with all my extensions, separated by "," or
    > >should I define some table?
    > >
    > >tia
    > >
    > >bartp
    > here's something I whipped up. You should be able to modify it as
    > necessary.
    >
    > function strDir(strPath)
    > Dim fil,fol,arrExt,FSO,intCtr,strOut
    > Set FSO = server.createobject("Scripting.FileSystemObject")
    > arrExt = Array("gif", "jpg", "tif") ' put your extensions in here
    > Set fol = FSO.GetFolder(strDir)
    > strOut = vbNullString
    > For Each fil In fol.Files
    > For intCtr = LBound(arrExt) To UBound(arrExt)
    > If StrComp(Mid(fil.ShortName, InStrRev(fil.ShortName, ".")
    > + 1), arrExt(intCtr), 1) = 0 Then
    > strOut = strOut & fil.Path & "<br>"
    > End If
    > Next
    > Next
    > set FSO=nothing
    > strDir=strOut
    > end function
    > %>
    >
    > <html>
    > <body>
    > <p><%=strDir("c:\pictures")%></p>
    > </body>
    > </html>
    >
    >
    > the function will return a string with <br> between the files. Of
    > course, you can put whatever you want in there for syntax, like
    > "<tr><td>" to return a HTML table, etc.
    >
    > Dan Bush
    > [email]meR3M0V3.danbush.com[/email]
    >

    bart plessers Guest

Similar Threads

  1. (PLEASE HELP) How to Filter List Box using XML PathExpression?
    By westleyct in forum Macromedia Flash Data Integration
    Replies: 0
    Last Post: March 13th, 10:27 AM
  2. Looking for bad word filter extension
    By Andrew in forum Macromedia Exchange Dreamweaver Extensions
    Replies: 0
    Last Post: March 3rd, 11:53 PM
  3. List of member for a group
    By Marin Marinov in forum Windows Server
    Replies: 2
    Last Post: June 9th, 06:00 PM
  4. Extension or script to send a newsletter as a pdf file to ane-mail list
    By MLangner-MMTS in forum Macromedia Dreamweaver
    Replies: 0
    Last Post: July 10th, 12:04 AM
  5. PHP : Dynamic List & Filter?
    By Tim L in forum Macromedia Dreamweaver
    Replies: 2
    Last Post: July 9th, 03:52 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139