Skip to content
This repository was archived by the owner on Jan 19, 2021. It is now read-only.

Commit a4ed0c8

Browse files
committed
Fix a property not loaded exception
1 parent 4a8e235 commit a4ed0c8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Commands/Base/BaseFileProvisioningCmdlet.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ protected void AddFileToTemplate(ProvisioningTemplate template, Stream fs, strin
119119
/// <param name="file">The SharePoint file to retrieve and add</param>
120120
protected void AddSPFileToTemplate(ProvisioningTemplate template, SPFile file)
121121
{
122-
var fileName = file.EnsureProperty(f => f.Name);
123-
var folderRelativeUrl = file.ServerRelativeUrl.Substring(0, file.ServerRelativeUrl.Length - fileName.Length - 1);
122+
file.EnsureProperties(f => f.Name, f => f.ServerRelativeUrl);
123+
var folderRelativeUrl = file.ServerRelativeUrl.Substring(0, file.ServerRelativeUrl.Length - file.Name.Length - 1);
124124
var folderWebRelativeUrl = HttpUtility.UrlKeyValueDecode(folderRelativeUrl.Substring(SelectedWeb.ServerRelativeUrl.TrimEnd('/').Length + 1));
125125
if (ClientContext.HasPendingRequest) ClientContext.ExecuteQuery();
126126
try
@@ -132,7 +132,7 @@ protected void AddSPFileToTemplate(ProvisioningTemplate template, SPFile file)
132132
// and the stream provided by OpenBinaryDirect does not allow it
133133
fi.Stream.CopyTo(ms);
134134
ms.Position = 0;
135-
AddFileToTemplate(template, ms, folderWebRelativeUrl, fileName, folderWebRelativeUrl);
135+
AddFileToTemplate(template, ms, folderWebRelativeUrl, file.Name, folderWebRelativeUrl);
136136
}
137137
}
138138
catch (WebException exc)

0 commit comments

Comments
 (0)