Package.Open() exception: Access to path is denied.

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi,
I been trying to fix this problem for the whole day, but no matter what I do I keep on getting the same exception: UnauthorizedAccessException was unhandled at line
using (Package package = Package.Open(d.FullName, FileMode.Create, FileAccess.ReadWrite))
The full code is:
NTAccount act = new NTAccount("c9lu-PC","c9lu");<br/>
<br/>
DirectoryInfo d = System.IO.Directory.CreateDirectory(path);//AT NOTEBOOK LEVEL<br/>
<br/>
DirectorySecurity security = d.GetAccessControl();<br/>
<br/>
security.AddAccessRule(new FileSystemAccessRule(act,FileSystemRights.FullControl,InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow));<br/>
<br/>
d.SetAccessControl(security);<br/>
<br/>
using (Package package = Package.Open(d.FullName, FileMode.Create, FileAccess.ReadWrite)) // where the exception occurs<br/>
{<br/>
<br/>
PackageHelper.createPart(package, "/pages.zip" , MediaTypeNames.Application.Zip,<br/>
(stream) =><br/>
{<br/>
using (var parts = ZipPackage.Open(stream, FileMode.Create))<br/>
{<br/>
}<br/>
}<br/>
<br/>
);<br/>
}
I really dont know what the problem is, please help me out.
Thanks

View the full article
 
Back
Top