Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7540329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:36:55+00:00 2026-05-30T07:36:55+00:00

I am trying to run an event which will search through the different files

  • 0

I am trying to run an event which will search through the different files in a given directory. The goal is to have it search for all files that begin with ‘SP_’, which are .sql files containing Stored Procedures. I would then like to add the full text of these Procedures to an array to be used later. This is causing an error when run, which I believe is because ‘FullProcedureArray()’, the string array I am trying to load does not have defined boundaries. When I declare it as ‘FullProcedureArray(7)’, or with some other value, it appears to run fine. But I don’t want to have to hard-code a boundary for ‘FullProcedureArray’; I would rather let it be defined by whatever the number of files in the folder is.

My question: Is there a way to declare ‘FullProcedureArray’ without having to give it an absolute value? I may just be missing something painfully obvious, but I haven’t worked with this type of array much in the past. Thanks in advance for your help.

    Dim AppDataLocation As String = "C:\Files\TestFiles\"
    Dim ProcedureArray As String()
    Dim ProcedureText As String
    Dim FullProcedureArray() As String

    Dim sourceDirectoryInfo As New System.IO.DirectoryInfo(AppDataLocation)

    Dim fileSystemInfo As System.IO.FileSystemInfo
    Dim i As Integer = 0
    For Each fileSystemInfo In sourceDirectoryInfo.GetFileSystemInfos
        If (fileSystemInfo.Name.Contains("SP_")) Then
            ProcedureArray = System.IO.File.ReadAllLines(AppDataLocation & fileSystemInfo.Name)
            ProcedureText = Join(ProcedureArray, "")
            FullProcedureArray.SetValue(ProcedureText, i)
            i = (i + 1)
        End If
    Next
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:36:56+00:00Added an answer on May 30, 2026 at 7:36 am

    An array by definition has a fixed upper bound. If you don’t want a fixed upper bound, don’t use an array. Use, for example, a List(Of String) instead:

    Dim AppDataLocation As String = "C:\Files\TestFiles\" 
    Dim ProcedureList As New List(Of String)
    
    Dim sourceDirectoryInfo As New System.IO.DirectoryInfo(AppDataLocation) 
    
    For Each fileSystemInfo As System.IO.FileSystemInfo In sourceDirectoryInfo.GetFileSystemInfos 
        If (fileSystemInfo.Name.Contains("SP_")) Then 
            Dim ProcedureText As String = _
                System.IO.File.ReadAllText(AppDataLocation & fileSystemInfo.Name) 
            ProcedureList.Add(ProcedureText)
        End If 
    Next 
    

    If, for some reason, you still need the result as an array afterwards, simply convert the list to an array:

    Dim myArray() As String = ProcedureList.ToArray()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to add a blur event to some form elements which will run
I'm trying to build a search engine that will check a list and then
I am trying to create a simplified search box that will match multiple columns
I'm trying to understand which events will be managed from an event disptach thread
I'm trying to schedule a repeating event to run every minute in Python 3.
I am trying run a program from a qmake .pro file which modifies the
Trying to run my program in FreeBSD OS, I have the following results: $
I have a web application which will return a user id based on the
I have a dotnet process that through calls to an unmanaged dll is communicating
I'm trying to build a really basic program that will alternate between two pictures

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.