Why c# deleting much faster than Windows bulit-in delete?

Oteg [oteg]
7 years ago | edited 7 years ago

0

I bought an external hard-drive, that was full with photos-videos, and much more trash. I tried to formatting, but i had to admit that will take hours or more. After that I tried to delete everything from it, but the same situation. I was very angry, tomorrow i will travel, and i need the external drive. So my last chance was the C#. I wrote a program(about 10 lines of code), and it deleted everything, in about 20 minutes.
So, why this “method” much faster than the built-in opportunities?

7replies
4voices
226views
theMunchBox
7 years ago

0

The only problem I see is that you are using a product by Microshit.

Oteg [oteg]
7 years ago

0

Sorry for my English, but if you try to refer to the product as subject, than, probably not this is the problem :D It’s a Samsung device, and not the cheapest model.

Oteg [oteg]
7 years ago

0

Sooo, yea I know Samsung isn’t good, but not the worst….

fearfullaughter
7 years ago

0

did you select “quick format” when you went to format it?

Oteg [oteg]
7 years ago

0

I tried both, but still the same result, It could take hours…

dloser
7 years ago

0

If quick format takes a long time, there has to be something wrong, I’d say. Perhaps you are using a very bad connection, or there are a lot of errors occurring.

I’m not sure about what Windows does exactly, but I can imagine that it first makes a list of all files (e.g. to display stats or check if all is ok), while your program probably only has to keep track of the current directory and iterate over the files in there (possibly even without first getting them all into a list or something). If there are a lot of files, I wouldn’t be surprised if this makes a big difference. If your system is low on memory, it perhaps even causes Windows to store so much that it starts swapping memory like crazy.

Oteg [oteg]
7 years ago

0

Probably, you’re right. And yes, there were a lot of files, more than 1 million and about 500 GB. So, thank you for your answers.

Discussion thread has been locked. You can no longer add new posts.
1 of 8

This site only uses cookies that are essential for the functionality of this website. Cookies are not used for tracking or marketing purposes.

By using our site, you acknowledge that you have read and understand our Privacy Policy, and Terms of Service.

Dismiss