you got a folder that needs to setup access rights during installation???
Win32Security dll can be used for this statue
here is the code block
DirectoryInfo imagesFolderInfo = new DirectoryInfo("the path of folder");
if (imagesFolderInfo.Exists)
{
// Give "NETWORK USER" user full access
SecurityDescriptor secDesc =
SecurityDescriptor.GetFileSecurity(
imagesFolderInfo.FullName,
SECURITY_INFORMATION.DACL_SECURITY_INFORMATION);
Dacl dacl = secDesc.Dacl;
dacl.AddAce(new AceAccessAllowed(new Sid("NETWORK SERVICE"),
AccessType.GENERIC_ALL | AccessType.STANDARD_RIGHTS_ALL,
/* AceFlags.OBJECT_INHERIT_ACE | */AceFlags.CONTAINER_INHERIT_ACE/*|AceFlags.VALID_INHERIT_FLAGS| AceFlags.SUCCESSFUL_ACCESS_ACE_FLAG*/));
secDesc.SetDacl(dacl);
secDesc.SetFileSecurity(
imagesFolderInfo.FullName,
SECURITY_INFORMATION.DACL_SECURITY_INFORMATION);
}
you can download Microsoft.Win32Security dll from that linkhttp://archive.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=WindowsFolderWebPart&DownloadId=665
**To Find out file path use Installer class' Context property
string logFileDirectory = string.Format("{0}Log", Context.Parameters["AssemblyPath"].Substring(0, Context.Parameters["AssemblyPath"].IndexOf("bin")));
this will return Log folder path
No comments:
Post a Comment