473,385 Members | 1,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Add Certain files in a Directory

I want to be able to have someone click a command button, then have a directory form show, that part is complete. Now i need help adding all the files in this directory to a list with the extensions ".mp3, .wav, and .mid".
(view code in discussion 'Directories and Listbox'
Aug 22 '07 #1
3 1113
Killer42
8,435 Expert 8TB
Here's a simple code snippet that uses the FileSystemObject model to find all the files in C:\Temp and load their names into a listbox. It assumes that you have listbox named List1 on your form, and that you have added to your project a reference to Microsoft Scripting Runtime.

Expand|Select|Wrap|Line Numbers
  1. Dim fso As New FileSystemObject
  2. Dim d As Folder
  3. Dim f As File
  4. Set d = fso.GetFolder("C:\Temp")
  5. For Each f In d.Files
  6.   List1.AddItem f.Name
  7. Next
  8. Set f = Nothing
  9. Set d = Nothing
  10. Set fso = Nothing
Aug 22 '07 #2
Here's a simple code snippet that uses the FileSystemObject model to find all the files in C:\Temp and load their names into a listbox. It assumes that you have listbox named List1 on your form, and that you have added to your project a reference to Microsoft Scripting Runtime.

Expand|Select|Wrap|Line Numbers
  1. Dim fso As New FileSystemObject
  2. Dim d As Folder
  3. Dim f As File
  4. Set d = fso.GetFolder("C:\Temp")
  5. For Each f In d.Files
  6.   List1.AddItem f.Name
  7. Next
  8. Set f = Nothing
  9. Set d = Nothing
  10. Set fso = Nothing
i got it working, thanks much
Aug 22 '07 #3
Killer42
8,435 Expert 8TB
i got it working, thanks much
Glad to help. :)
Aug 23 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Peter | last post by:
I have a site which uses forms authentication but I would like to exclude certain pages on the site from authentication. In other words I would like the user to be able to get to these pages...
1
by: - Steve - | last post by:
I have a directory that I want to use forms based authentication on. There's a couple of pages in that directory that I want to allow anonymous access to. There's also one page that I want to...
1
by: Steve Franks | last post by:
I'd like to set up a certain part of my web tree so that no browsers can access files from that directory and any directories below it. I will store certain resouces like xml files and other...
2
by: Brandon | last post by:
Running IIS 6, Classic ASP Browser: IE and/or Mozilla I have an application that allows users to store documents on my server. When they need to access/download the documents, my application...
3
by: =?Utf-8?B?TWF4IFR1cmF2YW5p?= | last post by:
Hi, Is there any way I can cause a login page to appear, using Forms authentication of course, when access a particular page only. In my case, I am building a site for rental properties. There...
3
by: galf | last post by:
Ok, I'm stuck. I'd like to list only specific types of files in a directory - for example, only html files. I've found a script that will list ALL of the files in the directory, but I'd like to...
1
by: Oltmans | last post by:
Hi all, I'm new to sub-version and still learning the process. We've a scenario in our office where we do a Svn-Update on a certain folder to fetch the latest code and then we deploy that...
15
by: spazzo6281 | last post by:
Hello, is there a way to search a folder for certain files containing a wildcard or certain text entered into a text box. Right now all i can get is the whole list of files from a folder using the...
15
by: Andy B | last post by:
I need to count files in a certain directory that has the string -Contract Template.xml at the end of it. How would I do this?
4
by: supriyamk | last post by:
Hi, I am trying to search a directory for subdirectories, recreate the subdirectories elsewhere and copy only certain files from current subdirectory to new subdirectory. In other words i am...
0
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...
0
isladogs
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.