Question

Were in the process of upgrading our DNN versions... and have run into a small hurdle.

Old deprecated code for DNN 5.4

Dim objFileController As New FileController
Dim objImageInfo As DotNetNuke.Services.FileSystem.FileInfo = objFileController.GetFileById(myFileId, myPortalId)

New attempt with 7.0.2

Dim objFileController As FileManager
Dim objImageInfo As DotNetNuke.Services.FileSystem.IFileInfo = objFileController.GetFile(myFileId)

A couple problems though, using the new methods...

1) This doesn't specify the Portal ID. We have multiple different portals and I need to be able to filter for just a specific one. There are other overloads where you can specify PortalID, but then you can't specify FileID...

2) I get a warning that the objFileController has been used before assigned a value. But if i put "Dim __ as New FileManager" then it throws a compile error because of the 'friend' context of FileManager.


* EDIT *

I'm seeing some references to FileManager.Instance.GetFile(FileID) . . . Does Instance just refer to the current portal of the site being run? If so, I could possibly use this, just passing in FileID...

Was it helpful?

Solution

  1. Files can only be in one portal, so if you have the file's ID, it isn't necessary to specify the portal ID. If you want to verify, you can check the PortalId property of the IFileInfo object that you get back.
  2. There isn't a public constructor exposed for FileManager, but you use the static Instance method instead, to get the current instance of the file manager (which is not specific to a portal).
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top