/src/Umbraco.Web/umbraco.presentation/EnsureSystemPathsApplicationStartupHandler.cs

https://github.com/solracnapod/Umbraco-CMS · C# · 41 lines · 38 code · 3 blank · 0 comment · 1 complexity · 20af9788f7a32a457d71755697c2e854 MD5 · raw file

  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Web;
  6. using Umbraco.Core;
  7. using Umbraco.Core.IO;
  8. using umbraco.businesslogic;
  9. using umbraco.interfaces;
  10. namespace umbraco.presentation
  11. {
  12. public class EnsureSystemPathsApplicationStartupHandler : ApplicationEventHandler
  13. {
  14. protected override void ApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
  15. {
  16. base.ApplicationInitialized(umbracoApplication, applicationContext);
  17. EnsurePathExists("~/App_Code");
  18. EnsurePathExists("~/App_Data");
  19. EnsurePathExists(SystemDirectories.AppPlugins);
  20. EnsurePathExists(SystemDirectories.Css);
  21. EnsurePathExists(SystemDirectories.MacroScripts);
  22. EnsurePathExists(SystemDirectories.Masterpages);
  23. EnsurePathExists(SystemDirectories.Media);
  24. EnsurePathExists(SystemDirectories.Scripts);
  25. EnsurePathExists(SystemDirectories.UserControls);
  26. EnsurePathExists(SystemDirectories.Xslt);
  27. EnsurePathExists(SystemDirectories.MvcViews);
  28. EnsurePathExists(SystemDirectories.MvcViews + "/Partials");
  29. EnsurePathExists(SystemDirectories.MvcViews + "/MacroPartials");
  30. }
  31. public void EnsurePathExists(string path)
  32. {
  33. var absolutePath = IOHelper.MapPath(path);
  34. if (!Directory.Exists(absolutePath))
  35. Directory.CreateDirectory(absolutePath);
  36. }
  37. }
  38. }