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

  • Home
  • SEARCH
  • 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 9079203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:47:16+00:00 2026-06-16T19:47:16+00:00

Using Visual Studio 2010 C#. I’m attempting to delete a folder in C:/Windows/MyFolderA where

  • 0

Using Visual Studio 2010 C#. I’m attempting to delete a folder in C:/Windows/MyFolderA where MyFolderA is a folder placed there by my software – Not Microsoft’s.

I’ve used this code to delete the contents of the folder and the folder itself:

foreach (FileInfo tempfi in listOfMSIInstallers)
{
    //Delete all Files
    DirectoryInfo localDirectoryInfo = new DirectoryInfo(targetDirectory);
    FileInfo[] listOfMSIInstallers = localDirectoryInfo.GetFiles("*",SearchOption.AllDirectories);
    File.SetAttributes(tempfi.FullName, File.GetAttributes(tempfi.FullName) & ~FileAttributes.ReadOnly); //Remove Read-Only
    File.Delete(tempfi.FullName); //Delete File

    string parentFolderPath = "C:/Windows/MyFolderA"; //Example string for StackOverflow

    //Remove ReadOnly attribute and delete folder
    var di = new DirectoryInfo(parentFolderPath);
    di.Attributes &= ~FileAttributes.ReadOnly;
    Directory.Delete(parentFolderPath);
}

If I attempt to delete the folder I get an exception

“System.IO.IOException: The directory is not empty”.

Showing invisible files on my GUI I do not see any. Looking at the folder with a command prompt there appears to be 2 directories: 1 named . and the second named .. (not too familiar with command prompt dir so I don’t know if they’re temp names or if those are the actual directory names) both at 0 files and 0 bytes.

Debugging through looking at the FileInfo[] object, it doesn’t grab the invisible files found from command prompt.

Any ideas how I can delete the files/directory?

  • 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-16T19:47:17+00:00Added an answer on June 16, 2026 at 7:47 pm

    Try

    Directory.Delete(parentFolderPath, true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im using Visual Studio 2010, windows form (c#). I need change decimals place of
I am using Visual Studio 2010 Professional. Is there a way for me to
I'm using Visual Studio 2010 on a Windows XP SP3 machine and I have
Using Visual Studio 2010 and I'm encountering an error when attempting to use the
I'm using Visual Studio 2010 sp1. with c++ and boost 1.47 in Windows 7
Using Visual Studio 2010, is there a way to run all unit tests in
i am using visual studio 2010 and Windows XP on a macbook through bootcamp.
Note: I'm using Visual Studio 2010. There are two important classes here, Date and
We are using Visual Studio 2010 connected to Team Foundation Server 2010 and we
I am using Visual Studio 2010 to create a setup project for my .NET

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.