Getting access denied while trying to create iis application from code

nealumber

New Member
I'm trying to create a application from a directory inside a IIS website. Basically what I'm trying to do is to reproduce this flow in code: right-click on a folder inside an IIS website and click to convert to application.this is my code:\[code\] DirectoryEntry appsRoot = new DirectoryEntry("IIS://localhost/w3svc/3/Root"); //Create and setup new virtual directory DirectoryEntry virtualDirectory = appsRoot.Children.Add(tool.Id.ToString(), "IIsWebVirtualDir"); virtualDirectory.Properties["Path"][0] = Path.Combine(AppConfig.ToolsFilePath, tool.Id.ToString()); virtualDirectory.Properties["AppFriendlyName"][0] = tool.Name; virtualDirectory.CommitChanges(); // IIS6 - it will create a virtual directory // IIS7 - it will create an application virtualDirectory.Invoke("AppCreate", 1);\[/code\]The error I get is Access is denied. \[code\]Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).\[/code\]
 
Top