3 ms·
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
by tracker1 8y ago
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
}
};
}