Is it possible to delete "C:" using Directory.Delete?

Asked

Viewed 76 times

4

Using Directory.Delete("C:", true) deletes partition? Or it is just locked and does not run?

  • Have you tried testing? maybe using the method Format of the API Win32_Volume can help with anything.

1 answer

4


Directory.Delete() is made to delete files and folders. It cannot erase a partition that is on a lower layer than the one you are using.

It will try to delete all folders from this partition, but it will depend on permissions. If you are running the application with administrator privilege it will cause a lot of damage. Still it will not erase everything. Other issues may prevent deletion, as the documentation shows.

Any attempt will depend on permission.

There is no special treatment for any situation.

If you want to understand the details, you can track his source code (have to follow the links). At some point it delegates to the operating system.

  • This goes for when participation is not the same as the operating system? I ask this because not always the operating system is installed in C:

  • @Gokussjgod that doesn’t make much sense.

  • 1

    And if he is invoked in D://... :D

  • @Wallacemaxters does not change anything, I will repeat: There is no special treatment for any situation. Any attempt will depend on permission.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.