首页 > 代码库 > Sitecore操作Media上传图片

Sitecore操作Media上传图片

            try            {                Sitecore.Resources.Media.MediaCreatorOptions options = new Sitecore.Resources.Media.MediaCreatorOptions();                options.Database = Sitecore.Configuration.Factory.GetDatabase("master");                options.Language = Sitecore.Globalization.Language.Parse(Sitecore.Configuration.Settings.DefaultLanguage);                options.Versioned = Sitecore.Configuration.Settings.Media.UploadAsVersionableByDefault;                options.Destination = "/sitecore/media library/Pampers/Images/Expert/doctor1";                options.FileBased = Sitecore.Configuration.Settings.Media.UploadAsFiles;                string filePath = "E:\\doctor1.png";                Sitecore.Data.Items.MediaItem sampleMedia = MediaManager.Creator.CreateFromFile(filePath, options);                this.divError.InnerText = sampleMedia.ID.ToString();            }            catch (Exception ex)            {                this.divError.InnerText = ex.Message;            }