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
========================================== 5 8356
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" <ya*********@skynet.be> wrote in message
news:3F***************@skynet.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" <ba**********@hotmail.com> wrote in message
news:e0**************@TK2MSFTNGP10.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
On Mon, 28 Jul 2003 01:39:31 +0200, "bart plessers"
<ba**********@hotmail.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 me@R3M0V3.danbush.com
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" <no*@any.address> wrote in message
news:bg**********@sparta.btinternet.com... "bart plessers" <ba**********@hotmail.com> wrote in message news:e0**************@TK2MSFTNGP10.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
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" <me@R3MOV3.danbush.com> wrote in message
news:nn********************************@4ax.com... On Mon, 28 Jul 2003 01:39:31 +0200, "bart plessers" <ba**********@hotmail.com> wrote:
Yan,
that was what I was looking for!
will try it tomorrow. Maybe you can provide me with some sytax? How to
buildthe 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 me@R3M0V3.danbush.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Joonas Paalasmaa |
last post by:
Hi,
When compiling Sketch's streamfilter C extension the errors below are
raised during linking. What could cause the errors?
(Python 2.3, MinGw 1.1 with GCC 2.95.3-6, Windows 98)
Here are...
|
by: Els |
last post by:
If I use <? include "file.html"; ?> in the html of my
document, do I _have_ to change the extension of that
document to .php, or would it still work and be valid if I
let it remain .html?
--...
|
by: Terry E Dow |
last post by:
Howdy,
I am having trouble with the objectCategory=group member.Count attribute.
I get one of three counts, a number between 1-999, no member (does not
contain member property), or 0. Using...
|
by: Rob |
last post by:
I want to copy files from one folder to another... but only if it is a
".txt" file...
Below should work, but how would you filter on ".txt" files only ?
Thanks !
Dim fileEntries As String()...
|
by: tasahmed |
last post by:
Hello Friends,
I wrote a function which scans the current working directory and lists out details such as directory/file owner, permission etc. The output of this script can be viewing in the...
|
by: rautsmita |
last post by:
hello friends ,
i am using to jdk6 and JAXB2.0, i have geomtry.xsd file i am trying to compile this file using jaxb but i got some error i.e.The particle of the type is not a valid restriction of...
|
by: Andrew Meador |
last post by:
I have a form (Change Card List by Status) with a check box
(cboNOT) and a list box (lstStatus). There is an Open Report button
that opens a report (Report - Change Card List) which uses a query...
|
by: Chris Rebert |
last post by:
On Sat, Sep 27, 2008 at 3:42 PM, Michael Crute <mcrute@gmail.comwrote:
Looking at the docs for the mimetypes module, it just guesses based on
the filename (and extension), not the actual contents...
|
by: igglepiggle |
last post by:
I have developed a form that runs a folder browser dialog and then details all filenames within the chosen folder in a listbox. Currently the filenames populate a 1-D array before they are written...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |