Get the attachments of forum posts

To get the attachments of a post, you must perform the following:

  1. Get the post.
    Get an instance of the specified post. For more information, see For developers: Query forum posts.
  2. Get the attachments.
    To get the attachments, you must call the GetAttachments extension method of the post instance. The method returns an array of MediaContent items, but their actual type is Document.

Here is a code example:

C#
using System;
using Telerik.Sitefinity.Forums;
using Telerik.Sitefinity.Forums.Model;
using Telerik.Sitefinity.Libraries.Model;

namespace SitefinityWebApp
{
    public class GetAttachmentsOfForumsPosts_GetPostAttachments
    {
        public static MediaContent[] GetPostAttachments(Guid postId)
        {
            ForumsManager forumsManager = ForumsManager.GetManager();

            ForumPost post = forumsManager.GetPost(postId);

            return post.GetAttachments();
        }
    }
}
Want to learn more?
Enhance your Sitefinity skills by enrolling in free training sessions. Become Sitefinity certified through Progress Education Community to strengthen your professional credentials.
New to Sitefinity?