本文整理汇总了C#中Folder.IsObjectPropertyInstantiated方法的典型用法代码示例。如果您正苦于以下问题:C# Folder.IsObjectPropertyInstantiated方法的具体用法?C# Folder.IsObjectPropertyInstantiated怎么用?C# Folder.IsObjectPropertyInstantiated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Folder
的用法示例。
在下文中一共展示了Folder.IsObjectPropertyInstantiated方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UploadDocumentToFolder
/// <summary>
/// Upload document to folder
/// </summary>
/// <param name="web">Web to be processed - can be root web or sub site</param>
/// <param name="filePath">Full path to the file like c:\temp\fuu.txt</param>
/// <param name="folder">Folder Name in the site</param>
public static void UploadDocumentToFolder(this Web web, string filePath, Folder folder)
{
if (!folder.IsObjectPropertyInstantiated("ServerRelativeUrl"))
{
web.Context.Load(folder);
web.Context.ExecuteQuery();
}
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;
Microsoft.SharePoint.Client.File uploadFile = folder.Files.Add(flciNewFile);
folder.Context.Load(uploadFile);
folder.Context.ExecuteQuery();
}
}