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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:14:09+00:00 2026-06-10T02:14:09+00:00

I have a folder with files (the files in this folder can variate in

  • 0

I have a folder with files (the files in this folder can variate in number):

XXX_1.jpg
XXX_2.jpg
ZZZ_1.jpg
ZZZ_2.jpg
BBB_1.jpg
YYY_1.jpg

I want to populate a listView that has two columns: Name & Count.

In this example, the listView should look like this:

XXX 2
ZZZ 2
BBB 1
YYY 1

How would I go about constructing a LINQ query to separate name & count from the items in the folder and then populate the listView with the name of the file + how many times its in the directory?

Here’s how I started:

IEnumerable<string[]> groups = originalFiles
                                .GroupBy(policyName => policyName.Split('_')[0])
                                .Select(g => g.ToArray());

                foreach (var group in groups)
                {
                    //add group name + count in listView
                }

I need to add Count() somewhere there but I’m not really sure.

  • 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-06-10T02:14:10+00:00Added an answer on June 10, 2026 at 2:14 am

    Try this

    var groups = orignalFiles.GroupBy(o => o.Split('_')[0])
                           .Select(o => new { 
                                               Name = o.FirstOrDefault().Split('_')[0], 
                                               Total = o.Count() 
                                            });
    

    Good Luck !!

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

Sidebar

Related Questions

I have some folder with different files. I want to use something like this:
I have a files structure like this: Class (folder): - User.php - Rule.php Scripts
Say I have this url: http://site.example/dir/ In this folder I have these files: test.ascx.cs
I have this program in Python which should save text files to a folder
In Eclipse (DDMS) I have folder shared_prefs, where located my SharedPreferences files. Can I
I have a folder with 200 files in it. We can say that the
I have a folder in '/sites/all/libraries/folder'. In this folder some html files are automatically
I have a folder that csv files are stored in. How can I get
Could someone help me with this? I have a folder with some files (without
Lets say I have a folder with the following jpeg-files: adfjhu.jpg Afgjo.jpg Bdfji.jpg bkdfjhru.jpg

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.