Try our conversational search powered by Generative AI!

Creating a PageFolder using Code




PageData newComment = DataFactory.Instance.GetDefaultPageData(blogdirpage.PageLink, PersonalBlogType, AccessLevel.NoAccess);

newComment.PageName = txtCreateBlog.Text;

DataFactory.Instance.Save(newComment, EPiServer.DataAccess.SaveAction.Publish, AccessLevel.NoAccess);



string virtualPathFromFolderId = VirtualPathUtility.Combine(pageDirectoryRootVirtualPath, VirtualPathUtility.AppendTrailingSlash(folderId.ToString()));

string pageDirectoryRootVirtualPath = VirtualPathHandler.PageDirectoryRootVirtualPath;

IPageDirectory ipageDirectory = HostingEnvironment.VirtualPathProvider.GetDirectory(pageDirectoryRootVirtualPath) as IPageDirectory;

UnifiedDirectory directory = HostingEnvironment.VirtualPathProvider.GetDirectory(virtualPathFromFolderId) as UnifiedDirectory;

if (directory == null)


directory = ipageDirectory.CreateSubdirectory(virtualPathFromFolderId, newComment);


When i tried to create a pagefolder using the above code i am getting a error message like "You are not authorized to create directory" .How can i solve this error

 Thanks in Advance


Oct 14, 2008 16:58

Try use the .GetPageDirectory(true) on the PageData-object.

Edited, Oct 14, 2008 21:30
Still I am getting the same error.I am using WindowsMemebershipProvider and  WindowsRoleProvider .Is that a problem?
Oct 15, 2008 7:28
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.