I have tryed this code
try
{
// If the directory doesn't exist, create it.
if (!Directory.Exists(@"C:\Program Files\Default Company Name\LegendsInvoice1.1\Invoices\"))
{
Directory.CreateDirectory(@"C:\Program Files\Default Company Name\LegendsInvoice1.1\Invoices\");
}
}
catch (Exception ec)
{
MessageBox.Show(ec.Message);
}
//////////////////////
DirectorySecurity sec = Directory.GetAccessControl(@"C:\Program Files\Default Company Name\LegendsInvoice1.1\Invoices\");
// Using this instead of the "Everyone" string means we work on non-English systems.
SecurityIdentifier everyone = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
sec.AddAccessRule(new FileSystemAccessRule(everyone, FileSystemRights.Modify | FileSystemRights.Synchronize, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow));
Directory.SetAccessControl(@"C:\Program Files\Default Company Name\LegendsInvoice1.1\Invoices\", sec);
The above code I written but in cdirectory folder is not creating its giving error "access denied" so please help me how to create folder in c directory with full permission and one more, I have access database when i install my project manually I need to give the permission is there any solution to give programatically?