Vulnerability in EPiServer.Forms

Try our conversational search powered by Generative AI!

DataExporter to export Global Files


I want to be able to export all files in the File Library when exporting, even if the file is not linked on any particular content item.

I have been able to hook into the DataExporter.Exporting event but I can't find how to include Global Files as a source.

Can anyone point me in the correct direction?

Here is what i have so far (obviously not working code)

    public class GlobalFilesExporter : IInitializableModule {
        public void Initialize(InitializationEngine context) {
            DataExporter.Exporting += Instance_Exporting;

        #region IInitializableModule Members

        public void Preload(string[] parameters) {

        public void Uninitialize(InitializationEngine context) {
            DataExporter.Exporting -= Instance_Exporting;


        public static void Instance_Exporting(object sender, EventArgs e) {
            var dataExporter = sender as DataExporter;
            //dataExporter.SourceRoots.Add(new ExportSource(ContentReference.GlobalBlockFolder, ExportSource.RecursiveLevelInfinity));
            dataExporter.SourceRoots.Add(new ExportSource("GlobalFiles???"));



Sep 11, 2013 7:52

The DataExporter class has a property FileTransfer that you can call method TryAddFile on. So what you need to do is to use EPiServer.Web.Hosting.GenericHostingEnvironment.VirtualPathProvider.GetDirectory("~/GlobalFiles") to get the root directory. Then you need to recursively traverse the structure below the root folder and call TryAddFile for each file.

In the upcoming CMS 7.5 files will also be handled as IContent implementations so then it will simply be a call to:

dataExporter.SourceRoots.Add(new ExportSource(SiteDefinition.CurrentOrDefault.GlobalMediaRoot, ExportSource.RecursiveLevelInfinity));

Sep 11, 2013 9:43
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.