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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:43:48+00:00 2026-05-13T16:43:48+00:00

I have a class that uses filesystem entities to manipulate data. We have several

  • 0

I have a class that uses filesystem entities to manipulate data. We have several methods specifically designed to (attempt to) cope with some of the issues we face with this approach (file locking, non-existent files, etc.). Ideally I’d like to be able to issue a warning if another developer attempts access the filesystem directly via System.IO rather than using the helper methods.

Is this possible? The behaviour I’m looking for is to effectively mark methods such as File.ReadAllText() as if they were obsolete, but only within this project (NOT solution-wide).

I’ve done some digging around, and it looks like my only option is “tell them to make sure they use your methods”. I’m hoping someone can give me a different, and more helpful answer. 🙂

–EDIT–
The suggestions of a custom StyleCop or FxCop rule are good, but unfortunately impractical in this scenario (not every developer in the department uses these excellent tools), and the legitimate methods that do the file access do use System.IO. Adding “ignore” attributes to the legit methods is a dangerous idea, too. If someone sees how I’ve “broken” my own rule, they’ll likely copy the attribute to their own method.

  • 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-13T16:43:48+00:00Added an answer on May 13, 2026 at 4:43 pm

    Use a static analysis tool (such as StyleCop or FxCop) with a rule that captures “Do not use System.IO directly.” Then integrate it as part of your automated build process and throw up if someone does try to use System.IO directly. No one likes to break the build.

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

Sidebar

Related Questions

I have a class that uses linq to access the database. Some methods call
I have a class that uses sockets to send and receive data asynchronously over
I have a controller class that uses asynchronous calls to perform some network operations.
I currently have a class that uses template arguments. I need an array of
Is it possible to chain metaclasses? I have class Model which uses __metaclass__=ModelBase to
I have a class from an external library that I want to extend with
Imagine that I have a generic base class like this: public abstract class AnimalDTO<TA,
I have a class that sets various session variables. After I set the session
I have a WCF ASP.Net 4.0 web service we'll call WebService. WebService is consuming
Alright this is the result of a couple of other questions. It appears I

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.