Skip to content

Instantly share code, notes, and snippets.

@neo125874
Created September 22, 2016 02:42
Show Gist options
  • Save neo125874/af5a545787163e9ae4f1fab5a7d4b710 to your computer and use it in GitHub Desktop.
Save neo125874/af5a545787163e9ae4f1fab5a7d4b710 to your computer and use it in GitHub Desktop.
PlayOnServer(global.asax.cs)
protected void Application_Start()
{
//check for bin files to be loaded
CheckAddBinPath();
}
public static void CheckAddBinPath()
{
// find path to 'bin' folder
var binPath = Path.Combine(new string[] { AppDomain.CurrentDomain.BaseDirectory, "bin" });
// get current search path from environment
var path = Environment.GetEnvironmentVariable("PATH") ?? "";
// add 'bin' folder to search path if not already present
if (!path.Split(Path.PathSeparator).Contains(binPath, StringComparer.CurrentCultureIgnoreCase))
{
path = string.Join(Path.PathSeparator.ToString(CultureInfo.InvariantCulture), new string[] { path, binPath });
Environment.SetEnvironmentVariable("PATH", path);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment