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 6916291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:35:00+00:00 2026-05-27T09:35:00+00:00

I have to rewrite some old code and I’m wondering the best way to

  • 0

I have to rewrite some old code and I’m wondering the best way to handle a long list of strings. The list is comprised of around 100 items, and each item is used to match a folder which may contain several files that will be added to a zip archive which will be named “[parentfolder].zip”

The current code looks something like this:

    string[5] list = {"a", "b", "c", "d", "e"};

    for (int i = 0; i < 5; i++){
        // open folder for list[i]
        if (Directory.Exists(string.Format("c:\\{0}", i))){
            // get files and add them to list[i].zip

            // do some work with archive
        }
    }

The list of folder names is not likely to change, but there is a small possibility that it will.

My question is what would be the best way to handle the list of folders? An array of strings is obviously not optimal. I was thinking of using an Enum, but would welcome any other suggestions as this ‘list’ seems like it could be easy to make errors in

(the item names are usually only three letters btw)

Sorry if this seems like a dumb question 😉

EDIT: orginally stated that the list of names is not likely to change, this was very badly stated as there is a small chance that the list will be added to.

  • 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-27T09:35:00+00:00Added an answer on May 27, 2026 at 9:35 am

    When I encounter scenarios like this I tend to prefer writing them to an file (xml or text). This also adds the advantage of not having to update code if folder names change or if new ones need to be introduced. You mentioned that neither of those two cases are likely to occur so the benefit is somewhat lost. This option is slower because of the IO operations involved in reading in the list so if you don’t need the benefits I mentioned then it may not be a good direction.

    In the end, a list or array is really the best fit if you can’t see the items changing or being added to.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm about to have to rewrite some rather old code using SQL Server's BULK
I'm trying to rewrite some old SQL into LINQ to SQL. I have a
I'm trying to rewrite some query strings I have in my URL like this
I want to have URLs like this: some-company-name-deal-id-6.htm So the rewrite rule should ignore
This is an attempt to rewrite some old homework using STL algorithms instead of
I have a VB6 application that still references some old VB5 libraries (dll, vbr,
I'm trying to setup some rewrite rules for a new Umbraco website we have.
I was working with some old code (a text game, as it happens) and
I have to rewrite the history of my repository because it contains some credentials.
I have to rewrite an old application and I would like to start using

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.