Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Read And Storing File Names In A Folder

Hi all,

So i got this folder in windows that has a bunch of .pdfs, now i would like to (using VB6) read these file names, i will then store them in a DB and compare the titels with existing files in the DB, anyone know how to read file titels in a specific folder and then use them as a string to compare trim count and print??


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How Do I Read The File Names In A Folder
Hi team

I need to get a list of all files in a folder and check if each one ends with "Mvermve.dbf". How do I do this?


Storing Names To A .txt File
i created a form called "EnterName.frm", inside this form there is a textbox called "txtName" and a command button called "cmdOK".

well my problem is how can i store the name input by the user in the textbox to a text file called "namelist.txt" upon the cmdOk is clicked?

the file "namelist.txt" will always store names whenever different users input their names in the textbox "txtName".

Storing Names To A .txt File
i created a form called "EnterName.frm", inside this form there is a textbox called "txtName" and a command button called "cmdOK".

well my problem is how can i store the name input by the user in the textbox to a text file called "namelist.txt" upon the cmdOk is clicked?

the file "namelist.txt" will always store names whenever different users input their names in the textbox "txtName".

Read An Excel File Using Vb And Storing That Data
i want to read an excel file using vb and storing that data
in database
can anyone provide me with the solution


How To Get The File Names In A Folder
I know the folder location but the filename is unknown and will change. I want to be able to extract the date in the filename. I have a code like this but i get an error object doesnt support property in the For statement

Dim sysfso,TempReport_Name,f,file

Set sysfso = CreateObject("Scripting.FileSystemObject")
set f = sysfso.GetFolder(fLocation)

for each file in f
TempReport_Name = file.Name

Get File Names From A Folder
I'm working on a little project at the moment. Its a Random Music Player, but for it to work the way I want it to I need to be able to get all the filenames onto my program


VB Code:
Dim FileName1 as String   Dim FileName2 as String   Dim FileName3 as String   Dim FileName4 as String   'Ect Ect  

However I have no idea on how to read the filenames, for purpose sake lets say the folder with all the music in is called "C:Music", how can i read all the filenames in this folder assuming that the number of files in the folder is always changing.

Cheers to anyone that can help

Get All File Names From A Folder
Hey all,

How can I get the names of all objects inside a folder with the microsoft scripting object?


Get File Names From A Folder
I have a bunch of files in a folder, and some of them are named "header_xxxx.dat". I want to get the "xxxx" part and put it in a combo box.

I have no idea where to start on figuring this out, so I'd appreciate some guidance. Thanks in advance.

I tried using a filelist box, but I want to filter out just the xxxx part, so that won't really do what I want.


Validate New File && Folder Names
What's the best way to validate new file and folder names? I need to give the user access to create both. A commondialog would work for files and handle any invalid characters, blank names, and invalid lengths. How can I go about doing this for new folders? Anyone?

Get An Array Of All File Names In A Folder
He's an easy one for you:

I want to be able to get a handle on all the file names in a folder and loop through them. Something like this:

dim sFileNameArray() as string

sFileNameArray = getAllfilesInFolder("full path here")

for i = 0 to ubound(sFileNameArray) - 1

'do something with file

next i

Does this make sense, seems pretty simple really, in fact I may have done it before, just cant remember. Do you use the FSO object?

How Do You Add All The File Names In A Folder To A Combobox
I need to add all the file names in folder "c:/myfiles" to combo1 .

Adding File Names In A Folder To A Listbox
I wanted to add all the names of the files in a folder in my computer to a list box in my vb program, so i used:

List1.AddItem Dir("G:foler1folder2")

So i expect to get the file names in the path i've chosen ("G:foler1folder2") to be added to List1. But there are 2 problems:

- the computer doesn't stop looping, so i need a code to tell it stop if there are no more files

- if the loop works, still the the program only adds the first file name to the listbox and keeps adding the first one in the loop.

a little help on this please, asap. thank u

Reading Folder And File Names From A Cd Drive
Hello everyone.

I am writing a program (or attempting to) that will read the folder names(0nly) and any file names listed below them in the 1st level of the directory. We don't want the files inside the folders.

Now we are going to read from a cd drive to make a CD File Management System. As I have searched until my eyes hurt in VBCity using Directory reading, file reading as search words. I haven't found anything that can help me. I don't even know where to begin. I would like to code it myself, but could use an API (if it exists) if that's what I have to do.

Any guidance or references is greatly appreciated. Thank you!!!!

Read The Names Of Files In A Zip File - VB6
Hi everyone,
Is it possible to read the files in given zip file from VB and write it into a textfile or populate the same in a grid/list/combo box? We should be able to capture the file extension as well.

How Do I Read File Names From A Directory
Can anyone help me with this?
I need to read a file name using FileSystemObject in a file directory and pass it to a variable one at a time.

Accessing Files With Different File Names From A Desktop Folder

I have been wanting to ask this question for awhile but have thought this would be impossible... well I now think nothing is impossible... so here is my setup and question:

I have many of these files in a folder on my desktop. Each one with exactly the same file name except for final part of the name, which is the date. e.g: blah blah blah_20050401 then: blah blah blah_20050402

Is there anyway to acess this folder, open a file, run my program, close the file without saving it, go back into the folder, open the next file, run the program, close without get the picture...

This is what I have to open the first file... Can I build from here?...or can I even do this...

ChDir "C:Documents and Settings1234567DesktopCompletion Files"
Workbooks.OpenText Filename:= _
"C:Documents and Settings1234567DesktopCompletion Filescfh2000_Completed_Orders_20050401.txt" _
, DataType:=xlDelimited, Tab:=True

As always... Thanks

Saving Then Printing MP3/CD Folder/file Names In A List

I am a 17 year old student from the uk

this isn't a project i have been given from school (i have just read the rules thingy.....but don't think i am just trying to get ya help for a project and cheat)

I'll try and explain

basically i have a collection of encoded MP3's that i have got from my CD's, and have burnt them onto mini CD's to play in my MP3 player

my mp3 player doesn't support file names, and so all i get is numbers. With mini cdr's holding approx 40/50 songs, and have numerous of these little CD's, i loose track of what is on what.

I would like to create a program that pulls off file names from the cds and puts them in order, much like explorer does (although explorer has file names and folder names in different sections, so i unfortunately cannot simply print screen)

folder 1 name
- file 1 name
- file 2 name
- and so on
folder 2 name
- file 1 name
- file 2 name
- etc

i would like it put it into a text file or other similar way to make it printable

any help would be greatly appreciated

i have looked on the net already but can't find a ready made program which will do the task as i wish it.

i asked my comp studies teacher and he said he couldn't work out how to do it..but he knows what he means (great help obviously)

thanks in advance for any help i recieve...i am afraid i have a very basic knowledge of programming


Skywalker (i have MSN messenger)
ICQ# 36240843

Getting All File Names From Folder, Editing Them And Putting Them Into A Textbox
Hi, I am a bit lazy. I have a folder with over a 1000 mp3s in and I want to list all of their names. I have created this

Private Sub Command1_Click()
Dim filter As String
filter = "MP3 Files Only (*.MP3)|*.MP3|"
CommonDialog1.FilterIndex = 1
CommonDialog1.filter = filter
CommonDialog1.Action = 1
Text1.Text = (CommonDialog1.FileTitle)
Dim OldFileName As String
Dim NewFileName As String
sOldFileName = Text1.Text
sNewFileName = Replace(Text1.Text, "[].mp3", "")
Text2.Text = Text2.Text + vbCrLf + Text1.Text
Text3.Text = Text3.Text + 1
End Sub

This copys a selected mp3's name into text2 and also counts which mp3 it was (I want to know the exact number of songs). But there is a problem. I want my songs in text2 to be with out "[].mp3", but the upper code doesn't work
Could some1 tell me what's wrong or just edit the code to work.

Also, is there a way that I can choose all the songs at once and not one at a time like in this case ?

Thanks for the help

How To Take File Names + Full Path From A Folder (Fastest Way)?
I have 1000s of files in a network folder, I want to take the file name and its full path of the entire files from that folder.

I know how to take this by looping each files in folders using FileSystemObject, but it takes long time. Is there any other fastest way to get it?

Thanks in advance.


How To Read The Database Structure (Table's Names And Fields Names?)
I'm usisng ADO and need to open a Database and show the table's names

Thanks for your help....

How Can I Open And Read A File From A %folder%
here is the code, I want to replace this path c: ext.txt by %TEMP%

in another words the file will exist in %TEMP%

here is the code:

VB Code:
Dim line As StringDim iFileNo As Integer     iFileNo = FreeFile         Open "C:Missing-Patches.txt" For Input As #iFileNo            Do Until EOF(iFileNo)                Line Input #iFileNo, line                    If line <> vbNullString Then                        List1.AddItem line                    End If            Loop        Close #iFileNo     End Sub

Read Registry Folder To File
I know how to read a registry string, but how do i take an entire folder out of the registry and save it as a .reg file ?


Copy File In A Read-only Folder
I am developing an Access application and i need to solve this problem:
in a form the user can copy a file in a folder of the lan but the file can not be modified after he has copied it.
If I set the user permission in the folder as read-only, of course I get an error when use CopyFile of File System Object.
If I set the attribute of the file as vbReadonly, the user could change it.
I don't want to map the folder with a special user in the code, because the user is already logged.

Thanks for helps and ideas


How Can Read File Or Folder Name With FindFirstChangeNotification Api
when we reaised event using FindFirstChangeNotification api function it do not return file or folder name in which event raised. So please tell me how can I read the file or folder name with these functions.

Storing Worksheet Names
Hello all -

I have a simple problem but haven't found a fix yet. I have a series of worksheets that all have similar data rearranged in the same way. A macro runs some simple analysis on the data set for "worksheet 1" only.

My question: Is there a way to store the user selected worksheet name into a variable and run the analysis macro on that active sheet?

- Just

Storing Variable Names In A String
Hi Listers,

I am having a string/variable problem, which I imagine is straight forward,
but I have not been able to solve at this stage.

I am storing an sql query in an access database where the text(query)
contains a mixture of text and variables that will be populated with values
when the query is used in the app...for example

"Select" & sqlfields & " from " & thmeDataset & " where " & sqlsearchfld & "
in (" & SelListStr & ");"

anyway , the problem that I am having, is that when I read the sql query in
(in VB 6) it is all recognised as a string, so the variable names are not
replaced with the values that they hold. if I were to assign the above query
to a text variable inside the vb code, then each variable would be replaced
with the associated value...

do any of you know of a way to get around this? Do I need to make a
procedure which passes the query in and figures out what is a variable and
what is not?

thanks in advance,


Phil Bright BSc(GIS)
GIS Programmer
Demography/Population Program
Secretariat of the Pacific Community (SPC)
B.P.D5, Noumea Cedex 98848
New Caledonia
Phone (687) 26.20.00 ext(226)
Fax (687) 26.38.18
E-mail: email@removed

Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (
Version: 6.0.380 / Virus Database: 213 - Release Date: 24/07/2002

Read A File In A Folder With File Name Given By User?

I have a set of files in a folder.I want to read a file in that folder,where the file name is given by the user at runtime.How to get filename from user and how to read that corresponding file from the folder.
If anyone know how to do it.Please let me know.
Thanks in Advance,

Storing Media In Database Vs. Storing Path To Media In A Folder
I'm building a media management tool and I'm trying to decide whether or not to store the media (images, flash movies, sound, etc.) in the database or to just store the path to the file in the database. Does anyone know the pros and cons of both methods?

Storing Multi User Names And Passwords
I really don't want to use the registry and I hit a snag tring to use ini's. With the InI I can store the user as a key and there password as its value but i can't retrive the password with out knowing which key to look at. I wanted to be able to loop through the keys and add them to a combobox also.
Any help would be great.

Storing Images In SQL Vs. Storing Path To Image File
I'm writing a document management application whereby users will be able to scan documents into the application. Then from within the applicaiton the users will be able to access the scanned documents.

So the debate is whether I should store the image directly in SQL Server (7.0) or simply store the path to the image and put the image on a network folder.

I have heard people recommend storing only the path and not the image itself but I don't know the reasons.

Obviously the database would be quite large but can't SQL server handle it? Backups would have to be performed either way so... I suppose if the database was corrupted then all images would be lost as opposed to single image files being corrupted on the harddrive.

I guess I'd like to hear what others have done in the past, their opinions, etc.

Thanks in advance.

Get All Folder Names Inside A Folder
what can i say, or what command can i use to get the names of all folders inside a path? also put the folder names in an array?

Storing A Folder&#039;s Contents In A Listbox
How do you store the contents of a folder in a list box?

I.E.>If I wanted to store all files located in the My Documnets folder in a list box.

W2000 File Names In FileListBox Are Are Dos Format Rather The Long Names

I have developed an application in VB5 under Windows 98. I am compiling the task and placing it in a network directory for common execution so an install is unnecessary. When the task is run from a W2000 box the long file names in a filelistbox get truncated to the old dos format maintaining the extension.

Storing Of Data That's Read Out From A TextFile.
ok..i had this problem to store the data that i retrieve from a Textfile into MS Access. It something like this, imagine you have a database of those customers who purchased the stuffs from a company all stored in a textfile. And you wanna grab those information in the textfile and put it into MS Access database. My question now is How do you grab those information and put it into MS Access database? i only want to grab the stuffs the purchase along with their ID for identification. The sample textfile below:

ID A01
NAME xxx
ADD 324 Bblah ablh Rd...
ItemNo 1
ItemName xyz
ItemPrice $1
ItemDetail wdwllelksdkwe
ItemNo 2
ItemName abc
ItemPrice $2
ItemDetail qwkdlksd
ID B01
NAME xxx
ADD 634 dfgslh Rd...
ItemNo 1
ItemName xyz
ItemPrice $4
ItemDetail wdwllelksdkwe
ItemNo 2
ItemName abc
ItemPrice $3
ItemDetail qwkdlksd

Basically, i'm doing something related to this. My textfile database is actually a SwissProt Human Database if you come across this. I just need to get the reference out which a single protein holds 1-10 records of references.
Thanks for the time reading this. By the way..i'm bad in Array if you suggestion is using Array. You might wanna explain more to me.

Getting Folder Names
I need to write a quick sub that basically takes in a directory path and outputs the names of every folder in that directory. Seems quite simple but I can't find anything in help. How can I do this?

Getting Folder Names Out Of Dir Box
how do i make a list of the current folders in the dirbox? i want it to look at the dirbox.. and make a list in a textbox of the current folders being viewed in the dirbox..

Getting Folder Names
i want to get the folder names from a removable drive. how can i do this?

Folder Names
How is a DOS folder name determined? Like on my computer, when I look through the console, I see "C:FolderProgra~2" Where did the 2 come from? Why not 1?

Is there a way, through code, to get the "dos version" of a folder name?

Folder Names In A Dir
How can I obtain all the names of the folders within another folder?

Get Folder Names...
I need a sub to get all the folders in a dir. And do this:

VB Code:
Winsock1.SendData FolderNameFolderName = FolderName + !

DO you get what I mean?
Get a folder name, Send the name, Get the next name, Send it and so on until all the folder names have been sent??

Folder Names
Quick Question:

How do you find the names of all folders in a certain directory?

Getting Folder Names
Does anyone know how to get the directory name? I tried doing and I get dir1 as the output.

The reason I ask is because I am looking to create a little app that will display all directories and files on a cd.

If anyone has any ideas or code that would be great.

Thanks in advance.

Getting Folder Names!!
I have a ListView and I need to populate it with all of the folders in a folder on my harddrive. How do I get these?


Getting Files Names In A Folder..
i have to get all the names of files contained in a specific folder to an excel sheet using macro. any help?


Capturing Folder Names
I wrote what I thought was a way to capure all the folder names for a directory. I've run into a few issues. One is that the DIR function sometimes returns the same folder name. I only want unique folder names so later, I can loop through these folders to look for files I need to open and read from. Also, from time to time, it saves a file into my array as a folder which causes a bad file name or number error when I try to use the DIR function inside what my program thinks is a folder (Not a file).

Here is my code.


Public Sub Get_Folders(sSource As String, sDest As String, sLastFolder As String)

On Error Resume Next

' find all folders in which the scorecards reside...

Dim T() As Excel_Files
Dim trec As Long

Dim lFrom As Long
Dim lTo As Long
Dim sPath As String
Dim X As Long

trec = 1
ReDim Preserve T(1)
T(1).sSource = sSource
T(1).sDest = sDest
T(1).sLastFolder = sLastFolder

lFrom = 1
lTo = trec


For X = lFrom To lTo

sPath = Dir(T(X).sSource, vbDirectory) 'retrieve the first entry...

Do While sPath <> "" 'start the loop...

'ignore the current directory and the encompassing directory...
If sPath <> "." And sPath <> ".." Then

'use bitwise comparison to make sure T(X).sSource & sPath is a directory...
If (GetAttr(T(X).sSource & sPath) And vbDirectory) = vbDirectory Then

If GetAttr(T(X).sSource & sPath) = vbDirectory Then

If T(X).sSource & sPath & "" <> T(trec).sSource Then

trec = trec + 1
ReDim Preserve T(trec)
T(trec).sSource = T(X).sSource & sPath & ""
T(trec).sDest = T(X).sDest
T(trec).sLastFolder = T(X).sLastFolder

End If

End If

End If

End If

sPath = Dir


Next X

If trec > lTo Then

lFrom = lTo + 1
lTo = trec

End If

Get_Files T(), trec

End Sub
You will notice in my code that I check the file attributes twice to make sure I have a folder or directory instead of a file. I know this is poor coding but I don't understand why, from time to time, the DIR function will return a file instead of a folder or directory. Any help solving this would be greatly appreciated...

Get The Names Of The Files In A Folder
How can I know the names of the files and folders in a given folder? I don't want to use the File List Box since I don't need any interaction with the user. I would need for instance to put the names in an array of strings.

Loading Folder Names
Ok, what i want to do is load all of the names of all folders in a certain directory. for instance, how would i load all of the folder names inside

app.path & "contacts"

into a list box, as well as an array, and then when a name is clicked in the list box, the names of the text files within that folder, are loaded into an array. how would i do this?

Get Folder Names From A Directory
I have a listbox and i want to populate it with all of the folders contained within C:Program Files. I only want the child folders to "Program Files", not the Granchild, etc.

How can i do this?

Getting Files From Folder (the Names )
How can I search the folder "C:arthurium"
for all of it files (include files in directories
under the top) and put the file names in a array?

Thanks alot!

[Edited by Evan on 08-20-2000 at 10:09 PM]

Copyright 2005-08, All rights reserved