Creating a PageFolder using Code

Vote:
 

Hi,

 

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

SADIK R

#25183
Oct 14, 2008 16:58
Vote:
 

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

http://sdk.episerver.com/library/cms5/html/M_EPiServer_Core_PageData_GetPageDirectory.htm

#25189
Edited, Oct 14, 2008 21:30
Vote:
 
Still I am getting the same error.I am using WindowsMemebershipProvider and  WindowsRoleProvider .Is that a problem?
#25193
Oct 15, 2008 7:28