Untergeordnete Seiten
  • PathManager

  Wiki Navigation

    Loading...


 Recently Updated


 Latest Releases

 MediaPortal 1.32
            Releasenews | Download
 MediaPortal 2.5
            Releasenews | Download


The interface IPathManager provides access to application-wide defined path registrations.

A path registration associates a special application file path (like the directory for log files) with a name (like <LOG>), called label. So the path manager provides access to a set of well-known file paths. If an application part needs to read or write from/to a file path, it can simply use the application's path manager.

In the following example, we want to read a file from the application's directory:

// Get the IPathManager from the current ServiceScope
IPathManager pathManager = ServiceScope.Get<IPathManager>();
string appDir = pathManager.Get("<APPLICATION_ROOT>");
// appDir will contain "c:\Program Files\MediaPortal", for example
// ... do something with the directory path

You can also use path labels in path expressions like "<APPLICATION_ROOT>/Skins", which specifies the "Skins" subdirectory of the application's installation path.

string skinDir = ServiceScope.Get<IPathManager>().Get("<APPLICATION_ROOT>/Skins");
// skinDir will contain "c:\Program Files\MediaPortal\Skins", for example
// ... do something with the directory path

Directory labels can be used to build new paths. new_label = <existing_label>/sub-directory

ServiceScope.Get<IPathManager>().SetPath("SKIN", @"<APPLICATION_ROOT>/Skins");
// <SKIN> can now be used in future to get the Skins path

The paths are calculated when requested, so that label changes will be used in future paths.

The path manager interface also supports adding/removing path registrations.

The following special paths are pre-defined:

APPLICATION_ROOT         = AppDomain.CurrentDomain.BaseDirectory
LOCAL_APPLICATION_DATA   = Environment.SpecialFolder.LocalApplicationData
COMMON_APPLICATION_DATA  = Environment.SpecialFolder.CommonApplicationData
MY_DOCUMENTS             = Environment.SpecialFolder.MyDocuments

Program default paths are loaded from a special xml file called Paths.xml located in the "<APPLICATION_ROOT>/Defaults/" directory.

<?xml version="1.0" encoding="utf-8"?>
<Paths>
  <Path name="DATA"
  value="&lt;COMMON_APPLICATION_DATA&gt;\MediaPortal" />
  <Path name="CONFIG" value="&lt;DATA&gt;\Config" />
  <Path name="LOG" value="&lt;DATA&gt;\Log" />
  <Path name="DATABASE" value="&lt;DATA&gt;\Database" />
</Paths>

For more information, see the docs for interface MediaPortal.Core.PathManager.IPathManager.

   

 

This page has no comments.