当前位置: 首页>>代码示例>>C#>>正文


C# FileCreationInformation类代码示例

本文整理汇总了C#中FileCreationInformation的典型用法代码示例。如果您正苦于以下问题:C# FileCreationInformation类的具体用法?C# FileCreationInformation怎么用?C# FileCreationInformation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FileCreationInformation类属于命名空间,在下文中一共展示了FileCreationInformation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: addToSpList

        /// <summary>
        /// Adds a file to a SharePoint list. Uses SharePoint server and login detailed in <c>AppSettings</c>
        /// </summary>
        /// <param name="fileName">File to be added</param>
        /// <param name="SPList">Sharepoint list to be added to. This list must be preexisting</param>
        public static void addToSpList(string fileName, string SPList)
        {
            string SPServer = ConfigurationManager.AppSettings["SPServer"];
            string USER = ConfigurationManager.AppSettings["user"];
            string PSWD = ConfigurationManager.AppSettings["password"];
            string DOMAIN = ConfigurationManager.AppSettings["domain"];

            //Create server context
            ClientContext context = new ClientContext(SPServer);

            //Authenticate sharepoint site
            NetworkCredential credentials = new NetworkCredential(USER, PSWD, DOMAIN);
            context.Credentials = credentials;

            Web web = context.Web;

            //Create file to add
            FileCreationInformation newFile = new FileCreationInformation();
            newFile.Content = System.IO.File.ReadAllBytes(fileName);
            newFile.Url = Path.GetFileName(fileName);

            //Get destination SP document list
            List list = web.Lists.GetByTitle(SPList);

            //Add file to SP
            Microsoft.SharePoint.Client.File uploadFile = list.RootFolder.Files.Add(newFile);

            //Load file
            context.Load(uploadFile);

            //Execute context into SP
            context.ExecuteQuery();
        }
开发者ID:jlipsun,项目名称:cps,代码行数:38,代码来源:FtpToSpService.cs

示例2: btnScenario_Click

        protected void btnScenario_Click(object sender, EventArgs e)
        {
            var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);
            using (var clientContext = spContext.CreateUserClientContextForSPHost())
            {
                Site site = clientContext.Site;
                clientContext.Load(site, s => s.Url);
                clientContext.ExecuteQuery();
                String webPartGalleryUrl = site.Url.TrimEnd('/') + "/_catalogs/wp";

                var folder = site.RootWeb.GetList(webPartGalleryUrl).RootFolder;
                //var folder = clientContext.Site.RootWeb.Lists.GetByTitle("Web Part Gallery").RootFolder;
                clientContext.Load(folder);
                clientContext.ExecuteQuery();

                //upload the "userprofileinformation.webpart" file
                using (var stream = System.IO.File.OpenRead(
                                Server.MapPath("~/userprofileinformation.webpart")))
                {
                    FileCreationInformation fileInfo = new FileCreationInformation();
                    fileInfo.ContentStream = stream;
                    fileInfo.Overwrite = true;
                    fileInfo.Url = "userprofileinformation.webpart";
                    File file = folder.Files.Add(fileInfo);
                    // Let's update the group for just uploaded web part
                    ListItem webpartItem = file.ListItemAllFields;
                    webpartItem["Group"] = "Add-in Script Part";
                    webpartItem.Update();
                    clientContext.ExecuteQuery();
                }

                lblStatus.Text = string.Format("Add-in script part has been added to web part gallery. You can find 'User Profile Information' script part under 'Add-in Script Part' group in the <a href='{0}'>host web</a>.", spContext.SPHostUrl.ToString());
            }
        }
开发者ID:CherifSy,项目名称:PnP,代码行数:34,代码来源:Default.aspx.cs

示例3: UploadConfigFileToSPO

        /// <summary>
        /// This method will upload uiconfigforspo.js into sharepoint catalog site collection
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="clientUrl"></param>
        public void UploadConfigFileToSPO(string filePath, string clientUrl)
        {
            using (ClientContext clientContext = spoAuthorization.GetClientContext(clientUrl))
            {
                
                
                var web = clientContext.Web;
                var newFile = new FileCreationInformation
                {
                    Content = System.IO.File.ReadAllBytes(filePath),
                    Overwrite = true,
                    //The root at which the uiconfigforspo.js needs to be uploaded
                    Url = Path.Combine("SiteAssets/Matter Center Assets/Common Assets/Scripts/", Path.GetFileName(filePath))

                };
                //The document library names under which the uiconfigforspo.js has to be uploaded
                var docs = web.Lists.GetByTitle("Site Assets");
                Microsoft.SharePoint.Client.File uploadFile = docs.RootFolder.Files.Add(newFile);
                clientContext.Load(uploadFile);
                clientContext.ExecuteQuery();
                //After uploading the file to sharepoint site collection, delete the file from the app root
                if(!filePath.EndsWith("config.js"))
                {
                    System.IO.File.Delete(filePath);
                }                
            }
        }
开发者ID:Microsoft,项目名称:mattercenter,代码行数:32,代码来源:ConfigRepository.cs

示例4: UploadDocumentContentStream

        /// <summary>
        /// Another valid approach for large files
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="library"></param>
        /// <param name="filePath"></param>
        public void UploadDocumentContentStream(ClientContext ctx, string libraryName, string filePath)
        {

            Web web = ctx.Web;
            // Ensure that target library exists, create if is missing
            if (!LibraryExists(ctx, web, libraryName))
            {
                CreateLibrary(ctx, web, libraryName);
            }

            using (FileStream fs = new FileStream(filePath, FileMode.Open))
            {
                FileCreationInformation flciNewFile = new FileCreationInformation();

                // This is the key difference for the first case - using ContentStream property
                flciNewFile.ContentStream = fs;
                flciNewFile.Url = System.IO.Path.GetFileName(filePath);
                flciNewFile.Overwrite = true;

                List docs = web.Lists.GetByTitle(libraryName);
                Microsoft.SharePoint.Client.File uploadFile = docs.RootFolder.Files.Add(flciNewFile);

                ctx.Load(uploadFile);
                ctx.ExecuteQuery();
            }
        }
开发者ID:AaronSaikovski,项目名称:PnP,代码行数:32,代码来源:FileUploadService.cs

示例5: UploadDocument

        public static void UploadDocument(string siteURL, string documentListName, string documentListURL, string DocuSetFolder, string documentName, FileStream documentStream, string status, string version, string contentID, string newFileName)
        {
            using (ClientContext clientContext = new ClientContext(siteURL))
            {

                //Get Document List
                Microsoft.SharePoint.Client.List documentsList = clientContext.Web.Lists.GetByTitle(documentListName);

                var fileCreationInformation = new FileCreationInformation();
                fileCreationInformation.ContentStream = documentStream;
                //Allow owerwrite of document

                fileCreationInformation.Overwrite = true;
                //Upload URL

                fileCreationInformation.Url = siteURL + documentListURL + DocuSetFolder + newFileName;

                Microsoft.SharePoint.Client.File uploadFile = documentsList.RootFolder.Files.Add(
                    fileCreationInformation);

                //Update the metadata for a field

                uploadFile.ListItemAllFields["ContentTypeId"] = contentID;
                uploadFile.ListItemAllFields["Mechanical_x0020_Status"] = status;
                uploadFile.ListItemAllFields["Mechanical_x0020_Version"] = version;
                uploadFile.ListItemAllFields["Comments"] = "Autogenerated upload";

                uploadFile.ListItemAllFields.Update();
                clientContext.ExecuteQuery();

            }
        }
开发者ID:rogerjo,项目名称:SupplierSites,代码行数:32,代码来源:Helper.cs

示例6: DeployModelInternal

        protected override void DeployModelInternal(object modelHost, DefinitionBase model)
        {
            var list = modelHost.WithAssertAndCast<List>("modelHost", value => value.RequireNotNull());
            var webPartPageModel = model.WithAssertAndCast<WebPartPageDefinition>("model", value => value.RequireNotNull());

            //if (!string.IsNullOrEmpty(webPartPageModel.FolderUrl))
            //    throw new NotImplementedException("FolderUrl for the web part page model is not supported yet");

            var context = list.Context;

            // #SPBug
            // it turns out that there is no support for the web part page creating via CMOM
            // we we need to get a byte array to 'hack' this pages out..
            // http://stackoverflow.com/questions/6199990/creating-a-sharepoint-2010-page-via-the-client-object-model
            // http://social.technet.microsoft.com/forums/en-US/sharepointgeneralprevious/thread/6565bac1-daf0-4215-96b2-c3b64270ec08

            var file = new FileCreationInformation();

            var pageContent = string.Empty;

            if (!string.IsNullOrEmpty(webPartPageModel.CustomPageLayout))
                pageContent = webPartPageModel.CustomPageLayout;
            else
                pageContent = GetWebPartTemplateContent(webPartPageModel);

            var fileName = GetSafeWebPartPageFileName(webPartPageModel);

            file.Url = fileName;
            file.Content = Encoding.UTF8.GetBytes(pageContent);
            file.Overwrite = webPartPageModel.NeedOverride;

            var newFile = list.RootFolder.Files.Add(file);

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioning,
                Object = newFile,
                ObjectType = typeof(File),
                ObjectDefinition = webPartPageModel,
                ModelHost = list
            });

            context.Load(newFile);
            context.ExecuteQuery();

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioned,
                Object = newFile,
                ObjectType = typeof(File),
                ObjectDefinition = webPartPageModel,
                ModelHost = list
            });
        }
开发者ID:nklychnikov,项目名称:spmeta2,代码行数:58,代码来源:WebPartPageModelHandler.cs

示例7: btnScenario1_Click

        protected void btnScenario1_Click(object sender, EventArgs e)
        {
            var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);

            using (var clientContext = spContext.CreateUserClientContextForSPHost())
            {
                if (clientContext != null)
                {
                    Web web = clientContext.Web;

                    List assetLibrary = web.Lists.GetByTitle("Site Assets");
                    clientContext.Load(assetLibrary, l => l.RootFolder);

                    // Get the path to the file which we are about to deploy
                    string file = System.Web.Hosting.HostingEnvironment.MapPath(string.Format("~/{0}", "CSS/contoso.css"));

                      // Use CSOM to uplaod the file in
                    FileCreationInformation newFile = new FileCreationInformation();
                    newFile.Content = System.IO.File.ReadAllBytes(file);
                    newFile.Url = "contoso.css";
                    newFile.Overwrite = true;
                    Microsoft.SharePoint.Client.File uploadFile = assetLibrary.RootFolder.Files.Add(newFile);
                    clientContext.Load(uploadFile);
                    clientContext.ExecuteQuery();

                    // Now, apply a reference to the CSS URL via a custom action
                    string actionName = "ContosoCSSLink";

                    // Clean up existing actions that we may have deployed
                    var existingActions = web.UserCustomActions;
                    clientContext.Load(existingActions);

                    // Execute our uploads and initialzie the existingActions collection
                    clientContext.ExecuteQuery();

                    // Clean up existing custom action with same name, if it exists
                    foreach (var existingAction in existingActions)
                    {
                        if (existingAction.Name.Equals(actionName, StringComparison.InvariantCultureIgnoreCase))
                            existingAction.DeleteObject();
                    }
                    clientContext.ExecuteQuery();

                    // Build a custom action to write a link to our new CSS file
                    UserCustomAction cssAction = web.UserCustomActions.Add();
                    cssAction.Location = "ScriptLink";
                    cssAction.Sequence = 100;
                    cssAction.ScriptBlock = @"document.write('<link rel=""stylesheet"" href=""" + assetLibrary.RootFolder.ServerRelativeUrl + @"/contoso.css"" />');";
                    cssAction.Name = actionName;

                    // Apply
                    cssAction.Update();
                    clientContext.ExecuteQuery();

                    lblStatus.Text = string.Format("Custom CSS 'contoso.css' has been applied to the <a href='{0}'>host web</a>.", spContext.SPHostUrl.ToString());
                }
            }
        }
开发者ID:nitewolfgtr,项目名称:PnP,代码行数:58,代码来源:Default.aspx.cs

示例8: AddFile

 public override SPDGFile AddFile(string url, byte[] content, bool overWrite)
 {
     FileCreationInformation fci=new FileCreationInformation();
     fci.Content = content;
     fci.Url = url;
     fci.Overwrite = overWrite;
     var file=_folder.Files.Add(fci);
     _context.Load(file);
     _context.Load(file.ListItemAllFields, SPDGClientListItem.IncludeExpression);
     _context.ExecuteQuery();
     return new SPDGClientFile(file, _context);
 }
开发者ID:Acceleratio,项目名称:SPDG,代码行数:12,代码来源:SPDGClientFolder.cs

示例9: OnProvisioningAsync

        protected override async Task OnProvisioningAsync()
        {
            var fci = new FileCreationInformation()
            {
                ContentStream = ContentStream,
                Overwrite = OverwriteExisting,
                Url = await HarshUrl.EnsureServerRelative(Folder.Value, FileName),
            };

            AddedFile = Folder.Value.Files.Add(fci);
            await ClientContext.ExecuteQueryAsync();
        }
开发者ID:NaseUkolyCZ,项目名称:HarshPoint,代码行数:12,代码来源:HarshCreateFile.cs

示例10: CreateMatterLandingPage

        /// <summary>
        /// Creates Matter Landing Page on matter creation
        /// </summary>
        /// <param name="clientContext">Client Context</param>
        /// <param name="client">Client object containing Client data</param>
        /// <param name="matter">Matter object containing Matter data</param>
        /// <returns>true if success else false</returns>
        internal static string CreateMatterLandingPage(ClientContext clientContext, Client client, Matter matter)
        {
            string response = string.Empty;

            if (null != clientContext && null != client && null != matter)
            {
                try
                {
                    using (clientContext)
                    {
                        Uri uri = new Uri(client.ClientUrl);
                        Web web = clientContext.Web;
                        FileCreationInformation objFileInfo = new FileCreationInformation();
                        List sitePageLib = null;
                        //// Create Matter Landing Web Part Page
                        objFileInfo.Url = string.Format(CultureInfo.InvariantCulture, "{0}{1}", matter.MatterGuid, Constants.AspxExtension);
                        response = CreateWebPartPage(sitePageLib, clientContext, objFileInfo, matter, web);
                        if (Constants.TRUE == response)
                        {
                            //// Configure All Web Parts
                            string[] webParts = ConfigureXMLCodeOfWebParts(client, matter, clientContext, sitePageLib, objFileInfo, uri, web);
                            Microsoft.SharePoint.Client.File file = web.GetFileByServerRelativeUrl(string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}{3}{4}", uri.AbsolutePath, Constants.Backslash, ConfigurationManager.AppSettings["MatterLandingPageRepository"].Replace(Constants.SPACE, string.Empty), Constants.Backslash, objFileInfo.Url));
                            clientContext.Load(file);
                            clientContext.ExecuteQuery();

                            LimitedWebPartManager limitedWebPartManager = file.GetLimitedWebPartManager(PersonalizationScope.Shared);
                            WebPartDefinition webPartDefinition = null;

                            string[] zones = { Constants.HeaderZone, Constants.TopZone, Constants.RightZone, Constants.TopZone, Constants.RightZone, Constants.RightZone, Constants.FooterZone, Constants.RightZone, Constants.RightZone };
                            AddWebPart(clientContext, limitedWebPartManager, webPartDefinition, webParts, zones);
                        }
                        else
                        {
                            response = Constants.FALSE;
                        }
                    }
                }
                catch (Exception ex)
                {
                    ////Generic Exception                    
                    MatterProvisionHelperFunction.DisplayAndLogError(errorFilePath, string.Format(CultureInfo.InvariantCulture, ConfigurationManager.AppSettings["ErrorMessage"], "creating Matter Landing page"));
                    MatterProvisionHelperFunction.DisplayAndLogError(errorFilePath, "Message: " + ex.Message + "\nStacktrace: " + ex.StackTrace);
                    throw;
                }

                return response;
            }
            else
            {
                return string.Format(CultureInfo.InvariantCulture, Constants.ServiceResponse, string.Empty, Constants.MessageNoInputs);
            }
        }
开发者ID:Microsoft,项目名称:mattercenter,代码行数:59,代码来源:MatterLandingHelperFunction.cs

示例11: btnScenario_Click

        protected void btnScenario_Click(object sender, EventArgs e)
        {
            var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);
            using (var clientContext = spContext.CreateUserClientContextForSPHost())
            {
                //Grab the web part gallery folder for uploading
                var folder = clientContext.Web.Lists.GetByTitle("Web Part Gallery").RootFolder;
                clientContext.Load(folder);
                clientContext.ExecuteQuery();


                //open the "scenario2.webpart" file
                ListItem item;
                using (var fileReadingStream = System.IO.File.OpenRead(
                                Server.MapPath("~/scenario2.webpart")))
                {
                    using (var workingCopy = new MemoryStream())
                    {
                        //read the file into an in memory stream for editing
                        fileReadingStream.CopyTo(workingCopy);
                        LabHelper.SetJsLink(workingCopy, this.Request);
                        //Reset the stream position for use during the upload
                        workingCopy.Position = 0;
                        //Use the FileCreationInformation to upload the new file
                        FileCreationInformation fileInfo = new FileCreationInformation();
                        fileInfo.ContentStream = workingCopy;
                        fileInfo.Overwrite = true;
                        fileInfo.Url = "scenario2.webpart";
                        File file = folder.Files.Add(fileInfo);
                        //Get the list item associated with the newly uploaded file
                        item = file.ListItemAllFields;
                        clientContext.Load(file.ListItemAllFields);
                        clientContext.ExecuteQuery();
                    }
                }

                // Let's update the group for the uploaded web part
                var list = clientContext.Web.Lists.GetByTitle("Web Part Gallery");
                if (item == null)
                {
                    lblStatus.Text = "Oh dear something went wrong while uploading the webpart";
                    return;
                }
                list.GetItemById(item.Id);
                item["Group"] = "App Script Part";
                item.Update();
                clientContext.ExecuteQuery();

                lblStatus.Text = string.Format("App script part has been added to web part gallery. You can find 'User Profile Information' script part under 'App Script Part' group in the <a href='{0}'>host web</a>.", spContext.SPHostUrl);
            }
        }
开发者ID:chrissimusokwe,项目名称:TrainingContent,代码行数:51,代码来源:Default.aspx.cs

示例12: CreateWebPartPage

        public int CreateWebPartPage(ClientContext clientContext, string pageName, string layout, string masterpagelistName, string listName, string pageTitle)
        {
            int response = -1;
            if (null != clientContext && !string.IsNullOrWhiteSpace(pageName) && !string.IsNullOrWhiteSpace(layout) && !string.IsNullOrWhiteSpace(masterpagelistName) && !string.IsNullOrWhiteSpace(listName))
            {
                try
                {
                    //// Find Default Layout from Master Page Gallery to create Web Part Page                

                    Web web = clientContext.Web;
                    ListItemCollection collection = spList.GetData(clientContext, masterpagelistName);
                    clientContext.Load(collection, listItemCollectionProperties => listItemCollectionProperties.Include(listItemProperties => listItemProperties.Id, listItemProperties => listItemProperties.DisplayName));
                    clientContext.ExecuteQuery();
                    ListItem fileName = null;
                    foreach (ListItem findLayout in collection)
                    {
                        if (findLayout.DisplayName.Equals(layout, StringComparison.OrdinalIgnoreCase))
                        {
                            fileName = findLayout;
                            break;
                        }
                    }
                    FileCreationInformation objFileInfo = new FileCreationInformation();
                    objFileInfo.Url = pageName;
                    Microsoft.SharePoint.Client.File fileLayout = fileName.File;
                    clientContext.Load(fileLayout);
                    clientContext.ExecuteQuery();
                    ClientResult<Stream> filedata = fileLayout.OpenBinaryStream();
                    List sitePageLib = web.Lists.GetByTitle(listName);
                    clientContext.Load(sitePageLib);
                    clientContext.ExecuteQuery();
                    StreamReader reader = new StreamReader(filedata.Value);
                    objFileInfo.Content = System.Text.Encoding.ASCII.GetBytes(reader.ReadToEnd());
                    Microsoft.SharePoint.Client.File matterLandingPage = sitePageLib.RootFolder.Files.Add(objFileInfo);
                    ListItem matterLandingPageDetails = matterLandingPage.ListItemAllFields;
                    // Update the title of the page
                    matterLandingPageDetails[ServiceConstants.TITLE] = pageTitle;
                    matterLandingPageDetails.Update();
                    clientContext.Load(matterLandingPageDetails, matterLandingPageProperties => matterLandingPageProperties[ServiceConstants.TITLE], matterLandingPageProperties => matterLandingPageProperties.Id);
                    clientContext.ExecuteQuery();
                    response = matterLandingPageDetails.Id;
                }
                catch (Exception)
                {
                    response = -1;
                }
            }
            return response;
        }
开发者ID:Microsoft,项目名称:mattercenter,代码行数:49,代码来源:SPPage.cs

示例13: CreateDocument

        /// <summary>
        /// Creates the document.
        /// </summary>
        /// <param name="memoryStream">The memory stream.</param>
        /// <param name="claimId">The claim id.</param>
        public void CreateDocument(MemoryStream memoryStream, string caseId, string claimId, string filename)
        {
            //return;
            try
            {
                if (_ctx != null)
                {
                    var list = _ctx.Web.Lists.GetByTitle(LibraryName);
                    _ctx.Load(list);
                    string file = string.Format("{1:yyyy-MM-dd_hh-mm-ss-tt}_{0}", filename, DateTime.Now);
                    string uploadLocation = string.Format("{0}/{1}/{2}", "http://dev8spt", LibraryName.Replace(" ", ""), file);

                    FileCreationInformation fileCreationInformation = new FileCreationInformation();
                    fileCreationInformation.Content = memoryStream.ToArray();
                    fileCreationInformation.Overwrite = true;
                    fileCreationInformation.Url = uploadLocation;

                    FileCollection documentFiles = list.RootFolder.Files;
                    _ctx.Load(documentFiles);

                    Microsoft.SharePoint.Client.File newFile = documentFiles.Add(fileCreationInformation);
                    _ctx.Load(newFile);

                    ListItem docitem = newFile.ListItemAllFields;
                    _ctx.Load(docitem);

                    _ctx.ExecuteQuery();

                    docitem[CaseIdKey] = caseId;
                    docitem[PrimaryKey] = claimId;
                    docitem.Update();

                    _ctx.ExecuteQuery();
                }
                else
                {
                    throw new Exception("Context Doesn't Exsist");
                }
            }
            catch (Exception ee)
            {
                throw ee;
            }
            finally
            {
                ConnectionClose();
            }
        }
开发者ID:Cognite-Soft,项目名称:ARB_2016_V2,代码行数:53,代码来源:DocumentRepository.cs

示例14: DeployModelInternal

        protected override void DeployModelInternal(object modelHost, DefinitionBase model)
        {
            var listModelHost = modelHost.WithAssertAndCast<ListModelHost>("modelHost", value => value.RequireNotNull());

            var list = listModelHost.HostList;
            var publishingPageModel = model.WithAssertAndCast<PublishingPageDefinition>("model", value => value.RequireNotNull());

            var context = list.Context;

            // #SPBug
            // it turns out that there is no support for the web part page creating via CMOM
            // we we need to get a byte array to 'hack' this pages out..
            // http://stackoverflow.com/questions/6199990/creating-a-sharepoint-2010-page-via-the-client-object-model
            // http://social.technet.microsoft.com/forums/en-US/sharepointgeneralprevious/thread/6565bac1-daf0-4215-96b2-c3b64270ec08

            var file = new FileCreationInformation();
            var pageContent = PublishingPageTemplates.RedirectionPageMarkup;

            // TODO, need to be fixed
            // add new page
            var fileName = publishingPageModel.FileName;
            if (!fileName.EndsWith(".aspx")) fileName += ".aspx";

            file.Url = fileName;
            file.Content = Encoding.UTF8.GetBytes(pageContent);
            file.Overwrite = publishingPageModel.NeedOverride;

            // just root folder is supported yet
            //if (!string.IsNullOrEmpty(publishingPageModel.FolderUrl))
            //    throw new NotImplementedException("FolderUrl for the web part page model is not supported yet");

            context.Load(list.RootFolder.Files.Add(file));
            context.ExecuteQuery();

            // update properties
            var newPage = list.QueryAndGetItemByFileName(fileName);

            // TODO
            // gosh, how we are supposed to get Master Page gallery with publishing template having just list here?
            // no SPWeb.ParentSite/Site -> RootWeb..

            //newPage["PublishingPageContent"] = "Yea!";
            //newPage["PublishingPageLayout"] = "/auto-tests/csom-application/_catalogs/masterpage/ArticleLinks.aspx";

            newPage.Update();

            context.ExecuteQuery();
        }
开发者ID:nklychnikov,项目名称:spmeta2,代码行数:48,代码来源:PublishingPageModelHandler.cs

示例15: Initialize

        public void Initialize()
        {
            clientContext = TestCommon.CreateClientContext();

            documentLibrary = clientContext.Web.CreateList(ListTemplateType.DocumentLibrary, DocumentLibraryName, false);
            folder = documentLibrary.RootFolder.CreateFolder(FolderName);

            var fci = new FileCreationInformation();
            fci.Content = System.IO.File.ReadAllBytes(TestFilePath1);
            fci.Url = folder.ServerRelativeUrl + "/office365.png";
            fci.Overwrite = true;

            file = folder.Files.Add(fci);
            clientContext.Load(file);
            clientContext.ExecuteQuery();
        }
开发者ID:AaronSaikovski,项目名称:PnP,代码行数:16,代码来源:FileFolderExtensionsTests.cs


注:本文中的FileCreationInformation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。