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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:20:30+00:00 2026-05-24T05:20:30+00:00

In my MVC app I’m returning files from a file server into my view.

  • 0

In my MVC app I’m returning files from a file server into my view.

To simplify my problem: Let’s say I have file1, file2, and file3 being returned from my Directory.GetFiles method. I’ve been instructed not to return file2, hence only showing file1 and file3 in my view.

Inevitably they’ll come a time when rules change and file2 will need to be showed again. What would be the smartest way to keep a list of the currently filtered out files and check against that list? (without setting the files to “hidden”); One idea I could do is write the filename in a repository and cross check against it, but I’m just worried about creating a maintenance catastrophe…

is there a better solution im overlooking?

  • 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-24T05:20:30+00:00Added an answer on May 24, 2026 at 5:20 am

    try

    var ForbiddenList = new string[] {"file2"};
    
    var Result = Directory.GetFiles().Except (ForbiddenList);
    

    EDIT – as per comment:

    Caching the result can be achieved rather easily…

    var FullList = Directory.GetFiles ();
    var ForbiddenList = new string[] {"file2"};
    

    Then you can choose what to display – when you need to display all then just use FullList, when you need to display only the existing forbidden Files you could FullList.Intersect (ForbiddenList) and when you need to display all without the forbidden files you do FullList.Except (ForbiddenList) .

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

Sidebar

Related Questions

I have an ASP.NET MVC app that opens a Request view in a new
I have an MVC app in Extjs 4 which has a View (extending Ext.panel.Panel
I have an MVC app with a Partial View (below). When I add Html.EnableClientValidation(),
General Info: ASP.NET MVC app using ADO.NET Entity Framework SQL Server 2005 I have
I have an MVC app divided into the usual layers: MVC presentation layer, Business
I have deployed my MVC app but when I browse from IIS I find
I have an MVC app via SharpArch. In the view I have: Html.DropDownListFor(x =>
In my ASP.net MVC App (using Razor views) I have a ProductDetails view. This
Hi I have an MVC app I'm calling a stored procedure from. The reason
I have a MVC app and using JQuery. I have anchor that I setup

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.