[other] Get path for programdata in plugin (1 Viewer)

pilehave

Community Skin Designer
  • Premium Supporter
  • April 2, 2008
    2,566
    521
    Hornslet
    Home Country
    Denmark Denmark
    Hi

    In earlier versions before the plugins were moved, I used this code to find the installpath. How do I find the ProgramData path instead? Both for Vista and XP....

    Code:
            private string GetMediaPortalPath()
            {
                string sRegRoot = "SOFTWARE";
                if (IntPtr.Size > 4)
                    sRegRoot += "\\Wow6432Node";
    
                RegistryKey MediaPortalKey = Registry.LocalMachine.OpenSubKey(sRegRoot + "\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MediaPortal\\", true);
                if (MediaPortalKey != null)
                {
                    return MediaPortalKey.GetValue("InstallPath").ToString();
                }
                else
                {
                    MediaPortalKey = MediaPortalKey.OpenSubKey(sRegRoot + "\\Team MediaPortal\\MediaPortal\\", true);
                    if (MediaPortalKey != null)
                    {
                        return MediaPortalKey.GetValue("ApplicationDir").ToString();
                    }
                    else
                        return null;
                }
            }

    :D
     

    ltfearme

    Community Plugin Dev
  • Premium Supporter
  • June 10, 2007
    6,751
    7,196
    Sydney
    Home Country
    Australia Australia
    Hi pilehave, try adding the namespace:

    using MediaPortal.Configuration;

    Then you can use the Config class to get all of MediaPortal's paths e.g.

    string configDir = Config.GetFolder(Config.Dir.Config);

    Hopefully that helps you.

    If you dont want to use this class, then you need to do as you did above to extract the MediaPortal binary directory then read paths from MediaPortalDirs.xml.
     

    pilehave

    Community Skin Designer
  • Premium Supporter
  • April 2, 2008
    2,566
    521
    Hornslet
    Home Country
    Denmark Denmark
    • Thread starter
    • Moderator
    • #3
    Hi pilehave, try adding the namespace:

    using MediaPortal.Configuration;

    Then you can use the Config class to get all of MediaPortal's paths e.g.

    string configDir = Config.GetFolder(Config.Dir.Config);

    Hopefully that helps you.

    If you dont want to use this class, then you need to do as you did above to extract the MediaPortal binary directory then read paths from MediaPortalDirs.xml.

    :D

    It works as it should, I was already using the Configuration class, so don't know why I overlooked this nice litte function :)
     

    Users who are viewing this thread

    Top Bottom