Reputation:
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,
Upvotes: 2
Views: 1265
Reputation: 7171
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);
}
Upvotes: 2