Guest User

Untitled

a guest
Apr 23rd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. public class WebApiApplication : System.Web.HttpApplication
  2. {
  3. protected void Application_Start()
  4. {
  5. CheckAddBinPath();
  6. GlobalConfiguration.Configure(WebApiConfig.Register);
  7. }
  8.  
  9. public static void CheckAddBinPath()
  10. {
  11. // find path to 'bin' folder
  12. var binPath = Path.Combine(new string[] { AppDomain.CurrentDomain.BaseDirectory, "bin" });
  13. // get current search path from environment
  14. var path = Environment.GetEnvironmentVariable("PATH") ?? "";
  15.  
  16. // add 'bin' folder to search path if not already present
  17. if (!path.Split(Path.PathSeparator).Contains(binPath, StringComparer.CurrentCultureIgnoreCase))
  18. {
  19. path = string.Join(Path.PathSeparator.ToString(), new string[] { path, binPath });
  20. Environment.SetEnvironmentVariable("PATH", path);
  21. }
  22. }
  23. }
Add Comment
Please, Sign In to add comment