Q:

How to remove windows user account folder using C#?

I have application which creates some windows user accounts, on uninstallation I remove the Windows User Account, but the folder for that user remains there (For example C:\Documents and Settings\UserName\"
How can I remove that folder using C#?
Thanks,

A:

Something along the lines of this?
DirectoryInfo dir = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
dir = dir.Parent.Parent.Parent;
DirectoryInfo[] userDirs = dir.GetDirectories(userName);

foreach (DirectoryInfo userDir in userDirs)
{
    userDir.Delete(true);
}

