Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find folder names in specified folder

Status
Not open for further replies.

LittleSmudge

Programmer
Mar 18, 2002
2,848
0
0
GB
I'm using A2k, running on Win2000 server machine.

Given that I can define a Server/Path name to a specific folder - how do I then gather the names of the folders within that into VB.

And once I've navigated to the bottom level - gather the names of the files therein.



( I'm needing to allow certain users { via the database } to view a limited portion of the file structure in order to retrieve SnapShots of reports that are stored there.
I don't want to use the CommonDialog because I can't limit their viewing to just the area I want.
So I'm planning to use the Tree control and populate it with the folders/subfolders/files that are in the relevant area.

- Or can anyone see an obvious solution that I've missed )





G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
Hi!

Could a recursive sub like the one PHV suggests here thread705-805195, be a start?

Roy-Vidar
 
Thanks Roy

The first part - checking if a folder exists and creating it if it doesn't I fixed based on your link using

Dim fso As Object
Dim strTargetFolder As String
strTragetFolder = "\\server\path\folder\"

Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FolderExists(strTargetFolder) Then
' Folder Exists so no action needed
Else
fso.Createfolder (strTargetFolder)
End If


and that's given me enough clues for the rest I think.

Thanks

G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
Hi

I've used code similair to that below (in A97 but it should work with A2k).

Which takes the file path as an argument and also has an optional file extention argument.
Then returns an array of the files found in the specified location.

Code:
Public Function strGetFiles(astrPath, Optional astrFileExtension As String)
    Dim strFileName As String
    Dim aryFileNames() As String
    Dim intAryCount As Integer
        
    strFileName = Dir(astrPath & "*" & astrFileExtension)
    Do Until strFileName = ""
        ReDim Preserve aryFileNames(intAryCount)
        aryFileNames(intAryCount) = strFileName
        
        intAryCount = intAryCount + 1
        strFileName = Dir()
    Loop

    strGetFiles = aryFileNames()
End Function

hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top