ASPX templates
Version 3.x > ASPX templates > Creating Document type Folder programatically View modes: 
User avatar
Member
Member
KenticoSB - 6/18/2008 11:58:28 AM
   
Creating Document type Folder programatically
How can I create the Document type Folder programmatically and use the folder to copy the files from shared folder to the Folder created in Kentico?

User avatar
Member
Member
kentico_vitaja - 7/1/2008 9:02:40 AM
   
RE:Creating Document type Folder programatically
Hi,

This is described in our documentation. Please see: http://kentico.com/docs/devguide/creating_documents.htm. You need to change this example so that it works for your site. For example
TreeNode node = new TreeNode("cms.news", provider);

you will change to
TreeNode node = new TreeNode("cms.folder", provider);

To copy files from your shared folder on a disc you need to do similar process - you will create cms.file documents under your cms.folder. Then you assign properties to these files.

Best regards,
Vita Janecek

User avatar
Member
Member
Luca - 10/22/2013 6:06:54 AM
   
RE:Creating Document type Folder programatically
Hi, Vita,

I'm trying to create new folder and append to an existing one but no success...
 var node = GetCurrentUserFolderNode(alisPath, cultureFormat);//Node found!
var folder = TreeNode.New("cms.folder");
folder.DocumentName = folderName;
folder.DocumentCulture="En-Us"
node.Children.Add(folder);
node.Update();

What's is wrong??

Thanks

User avatar
Kentico Support
Kentico Support
kentico_romank - 10/22/2013 7:25:02 AM
   
RE:Creating Document type Folder programatically
Hi,

If I understand your issue correctly, in content tree you have a folder and you want to append another folder to it, so basically you want to create subfolder, is that correct?

In that case please see http://devnet.kentico.com/docs/devguide/index.html?documents_api_examples_creating_documents.htm. In aliasPath you will have to specify the current folder, also you will have to use CMS.Folder instead of CMS.MenuItem.

Best Regards,
Roman Konicek