有没有人知道如何在site-core和asp.net中以编程方式更新filedropareafield?
按照以下代码:
Prod.Editing.BeginEdit();
using (new EditContext(Prod))
{
prod["image"]=
}
答案 0 :(得分:0)
var database = Sitecore.Configuration.Factory.GetDatabase("master");
var item = database.GetItem("{5306CEEC-AE8F-43D5-BA97-9F9551B2E50B}");
var field = (FileDropAreaField)item.Fields["FileDropArea"];
using (new EditContext(item))
{
var mediaCreator = new Resources.Media.MediaCreator();
MediaItem mediaItem = mediaCreator.CreateFromFile("D:\\Images\\myimage.jpg",
new MediaCreatorOptions()
{
FileBased = false,
Database = database,
IncludeExtensionInItemName = false,
Versioned = false,
Destination = "/sitecore/media library/imagefolder/uploaded/myimage",
Language = Language.Parse("en")
});
field.ChangeMediaFolder(database.GetItem("/sitecore/media library/imagefolder/uploaded"));
}