Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Gísli Freyr Svavarsson 43 posts 126 karma points
    Mar 11, 2016 @ 15:53
    GĂ­sli Freyr Svavarsson
    0

    .Count() not working on media

    I'm trying to get a count of media files in a folder but .Count() isn't working.

    var mediaFolder = Umbraco.TypedMedia(fontFolderId);
    int mediaCount = mediaFolder.Children.Count();
    

    The error I get is "'object' does not contain a definition for 'Count'" The foreach loop works fine when I get each item in the folder but the .Count f**ks everything up.

    Can someone point out to me what I'm doing wrong?

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Mar 11, 2016 @ 16:05
    Alex Skrypnyk
    0

    Hi Gisli,

    Do you inherit 'UmbracoViewPage' ?

    Thanks

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Mar 12, 2016 @ 10:55
    Dave Woestenborghs
    0

    Maybe you need to add using statement to your view :

    @using System.Linq
    

    Dave

Please Sign in or register to post replies

Write your reply to:

Draft