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

  • Home
  • SEARCH
  • 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 6909449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:41:27+00:00 2026-05-27T08:41:27+00:00

I currently have two arrays one the stores a file name and another that

  • 0

I currently have two arrays one the stores a file name and another that stores the file size. I need to show both the maximum file size and its name. I can get it to show the largest file by using this code.

        long[] fileSize;
        string[] fileName;
        fileSize = new long[fileCount];
        fileName = new string[fileCount];
        for (int index = 0; index < files.Length; index++)
        {
            fileSize[index] = files[index].Length;
            fileName[index] = files[index].Name;
        }
        long largestFile = fileSize.Max();
        string latestFileName = fileName[fileSize.Max()];
        Console.WriteLine("Total size of all files: {0}", totalSize);
        Console.WriteLine("Largest file: {1}, {0}", largestFile, latestFileName );

I have tried using google but it just tells me how to work out the maximum or minimum.

  • 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-27T08:41:28+00:00Added an answer on May 27, 2026 at 8:41 am

    There’s no need for separate arrays for the name and size, just loop over your files array, and keep track of the current max file size and it’s name in separate variables. Something like this:

    int max = 0;
    string name = string.Empty;
    
    for (int index = 0; index < files.Length; index++)
    {
        int size = files[index].Length;
        //check if this file is the biggest we've seen so far
        if (size > max)
        {
            max = size; //store the size
            name = files[index].Name; //store the name
        }
    }
    
    //here, "name" will be the largest file name, and "max" will be the largest file size.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I (currently) have two forms, one that needs to call the other. In other
I'm currently developing an app that uses Core Data. I'm using two stores/configurations, one
I currently have two panels within another large panel. The left panel is for
I have two arrays the store the values of two lines that are read
I am currently using markercluster plugin with jquery ui maps. I have two arrays
I currently have two arrays, 1 in each class, but I am cloning them
I have two models: Person and Relation. The second one stores information about relations
I have a site that dynamically creates two arrays of Lat/Long values based on
I currently have two apps: app1/ app2/ templates/ app1.html app2.html In app1.html, I'm including
I currently have two threads running in my program: Main thread - Grabs image

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.