Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. public static class EnvironmentVariables {
  2. public static void SetUp() {
  3. var configFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "Environment.config");
  4.  
  5. if(File.Exists(configFile)) {
  6. var lines = File.ReadAllLines(configFile);
  7.  
  8. foreach(var line in lines) {
  9. var index = line.IndexOf("=", StringComparison.Ordinal);
  10.  
  11. if(index > -1) {
  12. var key = line.Substring(0, index);
  13.  
  14. if(key.Trim() != "") {
  15. var value = line.Substring(index + 1);
  16. Environment.SetEnvironmentVariable(key, value, EnvironmentVariableTarget.Process);
  17. }
  18. }
  19. }
  20. }
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement