Forum Discussion
Cameron Andrews
Aug 24, 2017Copper Contributor
Special Characters(#, %) File Not Found when loading ListItem -> File -> Properties
With the addition of the new special characters we have come into a hiccup trying to support them in our 365 solution. The problem seems to occur when we attempt to load anything to do with a ListIte...
Arslan Qamar
Sep 07, 2017Copper Contributor
Detailed Repro steps :
1. Create 2 documents. One with a # or % in the file name, and one with neither of these characters
2. Create a ClientContext.
3. Get the existing ListItem objects through the context. (you should get a reference for both of the previously created files)
4. Execute the following code, where listItem is the ListItem with no special characters, and listItemSpecial is the Listitem with a # or %:
cxt.Load(listItem.File);
cxt.ExecuteQuery();
cxt.Load(listItem.File);
cxt.ExecuteQuery();
cxt.Load(listItemSpecial.File);
cxt.ExecuteQuery();
cxt.Load(listItemSpecial.File);
cxt.ExecuteQuery();
NOTE: The above code is not meant to be a realistic snapshot of how this bug occurrs in our code. It is simply the fastest way to reproduce the behaviour.
In reality, the above bug occurs when we load a file, and then try to access one of its properties a lot later in the code using the same context.
for example:
File file = listItem.File;
cxt.Load(file);
cxt.ExecuteQuery();
**we pass the file to a few different methods here**
if (file.Properties == null || file.Properties.FieldValues.Count == 0)
{
cxt.Load(file.Properties);
cxt.ExecuteQuery();
}
- Sep 07, 2017One question here: did you enable # and % support in your tenant? It might happen the source of the problem is just this...
- Cameron AndrewsSep 07, 2017Copper ContributorYes, # and % support was enabled for the tenant