Introduction

The EPiServer CMS File System is based on the Microsoft Virtual Path Providers (VPP) technology - EPiServer CMS uses VPP to serve static files to visitors from an underlying virtual file system. For information regarding VPPs see the Tech Note Virtual Path Providers in EPiServer CMS on EPiServer World and also the MSDN article ASP.NET Compilation Overview.

The File Management system in EPiServer CMS is accessed and used by web editors in the EPiServer UI where they can carry out tasks such as creating uploading files and creating a folder structure. When developing EPiServer solutions developers can also create functionality to upload, create, move, delete files and folders programatically.

For more general information regarding the File Management system in EPIServer CMS refer to the Administrator's Manual.

The EPiServer CMS file system is by default a versioned file system and stores the files in a GUID structure in the VPP folder. In EPiServer CMS all files are stored using the VirtualPathVersioningProvider (which always stores the path and file name in the database and the content as a file with a GUID as name).

Events

The EPiServer CMS API provides interfaces and classes for handling file and folders - see the EPiServer.Web.Hosting namespace.

By extending these classes when implementing your own file system (or using the existing EPiServer CMS File Management System) you can raise and subscribe to events for file and directory actions such as adding, deleting, renaming, versioning control, etc. All events support the pre- and post- mechanism (i.e. OnAdding – OnAdded).

Page Folders and Security

Each page in EPiServer CMS can have a folder to store files.

This folder when created is a 'regular' folder with a numeric name. This number has nothing to do with the specific page’s ID – the folder ID is picked according to a specific sequence. The ID of the page folder is stored in a property called PageFolderID on the page, see below.

CopyC#
int folderId = (int) Current.Property["PageFolderID"].Value;

Note that creating the page folder and storing files in the folder is also is tied to the page's access settings. If a visitor does not have access rights to read the page then they will not be able to read the files in the page's folder either.

One way to get the page folder from code is to call CurrentPage.GetPageDirectory(true) note that it will only work if the folder already exists or if you are logged in as an editor with the access rights in order to create pages.

 

Further Information

See the code examples in the How To folder.