private void SetPath(string storagePath)
{
if (storagePath == null) throw new NullReferenceException("Storage path cannot be null. Must be existing path.");
if (!System.IO.Path.IsPathRooted(storagePath))
{
if (storagePath.StartsWith("~/"))
{
System.Web.HttpContext context = System.Web.HttpContext.Current;
if (context != null)
storagePath = context.Request.MapPath(storagePath);
else if (System.Web.Hosting.HostingEnvironment.IsHosted)
storagePath = System.Web.Hosting.HostingEnvironment.MapPath(storagePath);
}
else
storagePath = Path.GetFullPath(storagePath);
}
if (!System.IO.Directory.Exists(storagePath)) throw new Exception("Storage path does not exist. The root of the path must exist before it can be used for storage.");
_path = storagePath;
}