Reputation: 69
With PnP PowerShell, I am able to get the value of "File_x0020_Type" like this:
$item = Get-PnPFile -Url $file.ServerRelativeUrl -AsListItem
Write-Host $item.FieldValues["File_x0020_Type"]
However, I am not able to find the equivelant code from PnP Core SDK. When I tried to run this code
var item = await f.ListItemAllFields.GetAsync();
Console.WriteLine(item["File_x0020_Type"]);
where f is an IFile already loaded, it throws error:
PnP.Core.ClientException: 'Property File_x0020_Type does not exist in this entity'
If I run this code
var item = await f.ListItemAllFields.GetAsync();
Console.WriteLine(item.Values["File_x0020_Type"]);
then I get error:
System.Collections.Generic.KeyNotFoundException: 'The given key 'File_x0020_Type**'.
I don't want to get the File Type from the file extension name because I've seen that it is possible for "File_x0020_Type" to be different from the file extension name, which was causing some issues for our client.
And because to query a large library using PowerShell is quite slow, I am trying to create a .NET6 console app utilizing PnP Core SDK instead.
Any help is very much appreciated.
Upvotes: 0
Views: 90