3 ms·
The whole environment handling bothers me, specially when working with containers. Why can't we have something normal like a .env?
by openbasic 8y ago
The whole environment handling bothers me, specially when working with containers. Why can't we have something normal like a .env?
- tracker1 8y agoThere'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 } }; }