Here is my code, and i tried same code for file access control, it works well. but doesn't work for common application data on Vista.
private static void GrantEveryoneFullControlRight(string directory)
{
try
{
if (!Directory.Exists(directory))
Directory.CreateDirectory(directory);
DirectoryInfo dirInfo = new DirectoryInfo(directory);
DirectorySecurity ds = dirInfo.GetAccessControl(AccessControlSections.Access);
FileSystemAccessRule rule = new FileSystemAccessRule(
"Users", FileSystemRights.FullControl, AccessControlType.Allow);
ds.AddAccessRule(rule);
dirInfo.SetAccessControl(ds);
}
catch (Exception ex)
{
// Logger.WriteLog(LogType.Error, ex.ToString());
Console.WriteLine(ex.ToString());
}
}