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?
try
EDIT – as per comment:
Caching the result can be achieved rather easily…
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 couldFullList.Intersect (ForbiddenList)and when you need to display all without the forbidden files you doFullList.Except (ForbiddenList).