Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • glenatron 37 posts 132 karma points
    Dec 15, 2013 @ 17:36
    glenatron
    0

    Can I access UmbracoSettings from my code in 6.1.6?

    I'm trying to create a custom MediaFileSystem for a site using Umbraco 6.1.6 and trying to base my code on the existing class as a starting point.

    The problem I am running into is that there are references to UmbracoSettings in the class:

                public string GetRelativePath(int propertyId, string fileName)
                {
                        var seperator = UmbracoSettings.UploadAllowDirectories
                                ? Path.DirectorySeparatorChar
                                : '-';
    
                        return propertyId.ToString() + seperator + fileName;
                }
    

    But UmbracoSettings appears to internal so I can't access it from my library.

    Is there another way of accessing data from umbracoSettings.config? It looks like there used to be an umbraco.UmbracoSettings but I can't find that either. Am I doing completely the wrong thing by even trying? If so, what should I be doing instead?

  • Sebastiaan Janssen 4899 posts 14655 karma points MVP admin hq
    Dec 16, 2013 @ 10:37
    Sebastiaan Janssen
    0

    Referencing all of the Umbraco dlls (I just have a class library in Visual Studio set up with the NuGet package UmbracoCms.Core added to it) I can do something like this:

    public class Class1
    {
        public static void Test()
        {
            var x = umbraco.UmbracoSettings.AddTrailingSlash;
        }
    }
    

    And I can access all other settings in the umbracoSettings.config.
    Yes, this is marked as obsolete, but still in the v7 codebase, so it won't go anywhere until at least v8.

    As I said on StackOverflow, you're probably better off using the Media Protect package or maybe you can use that and write a little bit of extra custom code to make it fit your needs.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies