Kentico中的AddAttachment方法

时间:2016-04-14 19:20:12

标签: c# attachment kentico

我们正在使用Kentico v9,并将Wordpress中的博客文章导入Kentico。我们在将附件导入博客文章时遇到问题。这是目前使用的代码:

var attachmentNode = TreeNode.New(FILE_PAGE_TYPE);
attachmentNode.DocumentName = filename;
attachmentNode.DocumentCulture = postNode.DocumentCulture;
attachmentNode.Insert(postNode);
DocumentHelper.AddAttachment(attachmentNode, "ce4c5d10-c143-4ada-9d8a-7e7481b167ef", localFileLocation, postNode.TreeProvider);
attachmentNode.Update();

这不会产生任何错误,并且数据库中存在该文件的记录。但是,文件本身不在Kentico中。有谁知道我在这里做错了什么?

2 个答案:

答案 0 :(得分:0)

请参阅Kentico DevNet中的answer I provided

public class RichTextLabel : RichTextBox
{
    public RichTextLabel()
    {
        BorderStyle = BorderStyle.None;
    }
}

答案 1 :(得分:0)

我认为这段代码不会对实际文件进行任何操作/处理 - 它只是将对该文件的引用保存到数据库中。如果要将其保存在文件系统中的特定位置,则必须实现适当的功能。 查看使用附件的一些examples API。