[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 254
  • Last Modified:

asp filenames into an array

I have a folder with n files and I need the names of these files to be loaded to an array.

5 files

dim files()
file(1)=´name1'
file(2)=´name2´
file(3)=´name3´
file(4)=´name4´
file(5)=´name5´

Si I can later open them and use their contents
0
robrodp
Asked:
robrodp
1 Solution
 
mvdeveloperCommented:
Use the Scripting.FileSystemObject as follows:


Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\my_folder")
Set arrFiles = objFolder.Files

You can then iterate through the files as follows:

Dim file()
Dim ct
ct = 0
For Each objfile in arrFiles
    ct += 1
    ReDim Preserve file(1 to ct)
    file(ct) = objFile.name
Next
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now