because of virtualization concept of win 7, normal standard user can not write that file.
so i have found one solution is
Assign everyone rights to that folder which is placed in programdata folder.
so any user can access & write that file.
to do this use below code.
DirectoryInfo dInfo = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\Procharge");
DirectorySecurity dSecurity = dInfo.GetAccessControl();
dSecurity.AddAccessRule(new FileSystemAccessRule("everyone",FileSystemRights.FullControl, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit,PropagationFlags.InheritOnly,AccessControlType.Allow));
dInfo.SetAccessControl(dSecurity);
No comments:
Post a Comment