Tuesday, January 5, 2010

Admin is not Admin in WIndows Vista !!


The directory access and Write permision using code in Vista is in blocked state. so Project working in Xp will do HELL in vista throwing access exceptions.....

to over come this add manifest file from project add new item and precombile it thus Avoid that Vista Hell....
So that we are able to pull the Vista UAC .............

Monday, January 4, 2010

create fullcontrol to a directory for windows machines

System.Security.Principal.SecurityIdentifier sid = new System.Security.Principal.SecurityIdentifier(System.Security.Principal.WellKnownSidType.WorldSid, null);
System.Security.Principal.NTAccount acct = sid.Translate(typeof(System.Security.Principal.NTAccount)) as System.Security.Principal.NTAccount;
string strEveryoneAccount = acct.ToString();



DirectoryInfo dInfo = new DirectoryInfo(Environment.CurrentDirectory + "\\serverservice");
DirectorySecurity dSecurity = dInfo.GetAccessControl();
dSecurity.AddAccessRule(new FileSystemAccessRule(strEveryoneAccount, FileSystemRights.FullControl, AccessControlType.Allow));

dInfo.SetAccessControl(dSecurity);