Sorry that i mislead you. I had overlooked the fact that the FileManager is located within the DotNetNuke website which is a just-in-time compiled website project (WSP). So, while you can load the module control using LoadControl, you cannot cast it to it's actual class type, DotNetNuke.Modules.Admin.FileManager.FileManager. Nor is it possible to add in your module project a reference to the DotNetNuke website project.
The only way that I see you might accomplish this, and I havn't tried it nor can really recommend it, is to make your custom module a WSP in the the DotNetNuke webspace. It would then be compiled just-in-time along with the DotNetNuke website as opposed to being a pre-compiled website application project (WAP). It would not have it's own project file (csproj or vbproj). Instead of doing a LoadControl in code, your module control (ascx) would then include a reference to the FileManager.ascx an <% @Register . . .%> directive as follows:
<%@ Control language="cs" Inherits="MyCompany.MyModule" CodeFile="MyModule.ascx.vcs" AutoEventWireup="false" %>
<%@ Register TagPrefix="dnn" TagName="FileManager" Src="~/DesktopModules/Admin/FileManager/FileManager.ascx" %>
<div>
<dnn:FileManager id="ctlFileManager" runat="server" ></dnn:FileManager>
</div>
You should then be able to reference the properties of the ctlFileManager object in your CodeFile (rather than CodeBehind - same idea but different terminology for a WSP project).
I mentioned that I consider the reuse of DNN module controls as user controls in one's own projects as being a "bit on the edge of good practice" for the following reasons:
- Unlike core user controls such as the UrlControl, Label, etc, the module controls were never designed to be incorporated into other module controls.
- Since the control is not designed for other usage its entire design, namespace, properties, etc. might change in a later version rendering your module control useless.
- In the case of this specific module control which relies heavily on client-side code for the folder tree I suspect that you may run into some problems with missing client side script registration as well as permissions if the control is to be used by non-admin users. Not impossible to work around but an additional layer of complexity.
As for other approaches, it depends on what you are trying to accomplish with your module. If you are looking for only a subset of the functionality of FileManager - for example file upload or displaying a list of files in a folder, you are better to use other controls such as the UrlControl, DnnFilePicker, etc. and to study the source code of the FileManager for ideas on how to accomplish your specific needs.