mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-05 18:48:41 +00:00
25 lines
609 B
C#
25 lines
609 B
C#
namespace SharpbinV3.Server
|
|
{
|
|
/// <summary>
|
|
/// https://dusted.codes/dotenv-in-dotnet
|
|
/// </summary>
|
|
public static class DotEnv
|
|
{
|
|
public static void Load(string filePath)
|
|
{
|
|
if (!File.Exists(filePath))
|
|
return;
|
|
|
|
foreach (var line in File.ReadAllLines(filePath))
|
|
{
|
|
var parts = line.Split('=', StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
if (parts.Length != 2)
|
|
continue;
|
|
|
|
Environment.SetEnvironmentVariable(parts[0], parts[1]);
|
|
}
|
|
}
|
|
}
|
|
}
|