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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:07:30+00:00 2026-06-06T20:07:30+00:00

Recently I was debugging a poof-all-customer-data-is-gone problem. It did not take much time to

  • 0

Recently I was debugging a “poof-all-customer-data-is-gone” problem. It did not take much time to figure out that a wrong branch led to a Directory.Delete(customerRoot, true) line of code. The catastrophic line was written by a regular GUI developer. There are not many lines that can lead to such a disaster. So my question is how to prevent this particular call. (DirectoryInfo.Delete() is the second one).

Here is my prioritized list of possible solutions

  • Compilation error with no third parties altering a build process
  • Run-time interception with no third parties
  • Run-time interception with third party (no altering a build process)
  • Compilation error with third party (I guess PostSharp will do it)
  • Educational seminar for GUI developers about how customers love their data

Any other idea?

I will mention that our system has a dedicated service (validated and logged) for file/folder delete.

  • 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-06T20:07:32+00:00Added an answer on June 6, 2026 at 8:07 pm

    To “intercept” the call at runtime, you can use the FileSystemWatcher class, but it wont actually prevent the deletion, just let you know it’s happened. Preventing the actual deletion is a lot trickier. Windows does not offer Linux’s ptrace functionality, so you cannot intercept the system call itself (there is an article about that here but the usability is fairly limited from what I can tell). What others suggest – setting access rights and trust levels – might work, but when you do actually need to delete something and your “deletion service” is just a wrapper around the .NET methods, you will prevent that from working, too.

    The other option is to go for third party tools and check this at compile time – this question has just what you need for that, including examples, and there’s a lot more tools that can do this (I only use Resharper, but I would imagine it can accomplish the task as well).

    However, I dont think thats the point here. Your dev made a mistake, it whacked some customer data and nobody’s happy about that. It doesnt mean you need to make a system-wide rule of it and enforce that rule, it means the dev should have tested his or her code better and/or should have used the deletion service you mention (whatever that is). No matter how hard you try, you cant prevent people from doing stupid things. You dont want to spend time and money making fortifications around the Directory.Delete() method only to find out that someone else made a different silly mistake and this particular thing will never be an issue again. Unless problems like this (misusing Directory.Delete() ) are prone to happen more than usual in your system, let it go, concentrate on other things.

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

Sidebar

Related Questions

I was recently debugging a problem where a result was much larger than expected.
Recently I was debugging a project and the debugger (GDB 7.1) crashed all of
I spent a lot of time recently reading about debugging. One of the aspects
In our current windows mobile project a problem while debugging recently arised. When trying
I was recently tasked with debugging a strange problem within an e-commerce application. After
I recently spent a long while debugging something that turned out to be an
I've recently had a horrible problem with QTCreator. After the first time of running
I've been getting an error recently while debugging an ASP.NET application in Visual Studio
I recently ran into a familiar javascript/jQuery timing bug and spent too long debugging
Recently, sometimes (rarely) when we export data from our application, the export log contains

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.