question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to recurisly delete folder

See original GitHub issue

The below code seems to generate a folder not empty Exception but I’m unsure why.

Would you have any idea’s for me to try.

try
{
    var info = vhdbNtfs.GetDirectoryInfo("AppData\\Local");
    if (info != null)
    {
        var dirs = info.GetDirectories();
        foreach (var dir in dirs)
        {
            dir.Delete(true);
        }
    }
}
catch(Exception ex)
{
    var error = ex;
}

Unable to delete non-empty directory

My understanding is that Delete(true) should recursively delete all folders/files.

Issue Analytics

  • State:open
  • Created 8 months ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
Jimmy062006commented, Jan 27, 2023

I can confirm that resolves my issue but will leave this open for you to deal with 😃

0reactions
LTRDatacommented, Jan 27, 2023

Yes. That seems to work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Cannot delete directory with Directory.Delete(path, true)
If you are trying to recursively delete directory a and directory a\b is open in Explorer, b will be deleted but you will...
Read more >
How to recursively delete directory from command line in ...
We create a new empty folder called (strangely enough!) "new folder". We then use the robocopy command, telling it the source folder is...
Read more >
Unable to recursively delete directories in OneDrive ...
My current manual workaround is to delete all of the contents ( find . -type f -delete ), then synchronize, then loop deleting...
Read more >
Delete a Directory Recursively in Java
Learn how to delete a directory recursively in plain Java, and by using external ... Unable to visit a file – rethrow IOException...
Read more >
Ansible can't recursively delete a directory
Ansible can't recursively delete a directory ... But the directory did not get deleted. Is there any force/recursive parameter I can add? What...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found