How to get the ImageUrl in DotNetNuke with FileID only

DotNetNuke provides the possiblility to upload Files. Instead to save whole file-paths its easier to store just a single integer. The CMS is responsible to map the actual file-location to the file represented. By storing a reference this allows you also to easily build slideshows, galleries or similar.
1 answer

Code Snippet

DotNetNuke provides a class which provides the funktionality to get the object representing a file stored.
This enables us to easily store, retreive and assign files to links, images or others.

var image = (FileInfo)DotNetNuke.Services.FileSystem.FileManager.Instance.GetFile(FileId);
if (image != null){
img_Image.ImageUrl = DotNetNuke.Services.FileSystem.FileManager.Instance.GetUrl(image);
}

Taggings: