News for hackers. Stuff that matters.
Re:Is ASP.NET Core Now a Mature Platform? by tracker1 on Wednesday December 19, 2018 @03:52PM (#18719484)
There's a couple dotenv nuget packages...

    using DotEnv = dotenv.net.DotEnv;
But I wish the usage for the default load scenario was better. Here's how I'm using it.

        public static void Init()
        {
            var levelsToCheck = 4;
            var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory());

            for (; currentDirectory != null && levelsToCheck > 0; levelsToCheck--, currentDirectory = currentDirectory.Parent)
            {
                foreach (var fi in currentDirectory.GetFiles(".env", SearchOption.TopDirectoryOnly))
                {
                    DotEnv.Config(false, fi.FullName);
                    return; // found .env file
                }
            };
        }

There are no comments on this comment yet.