Exemplo n.º 1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="element"></param>
 /// <returns></returns>
 public static bool IsAbsolutePathExists(ScriptElement element)
 {
     return System.IO.File.Exists(GetAbsolutePath(element));
 }
Exemplo n.º 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="element"></param>
        /// <param name="extension"></param>
        /// <returns></returns>
        public static bool IsValidExtension(ScriptElement element, string extension)
        {
            if (null == element || string.IsNullOrEmpty(element.Path)) return false;

            string path = element.Path;
            int index = 0;
            if ((index = path.IndexOf('?')) != -1) path = path.Remove(index);
            string ext = System.IO.Path.GetExtension(path);
            if (string.IsNullOrEmpty(ext)) return false;
            else return string.Equals(ext, extension, StringComparison.OrdinalIgnoreCase);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        public static string GetAbsolutePath(ScriptElement element)
        {
            string _absolutePath = string.Empty;

            if (null != element)
            {
                if (!element.Path.StartsWith("~", StringComparison.OrdinalIgnoreCase) && !element.Path.StartsWith("/", StringComparison.OrdinalIgnoreCase))
                    _absolutePath = System.Web.HttpContext.Current.Server.MapPath("~/" + element.Path);
                else
                    _absolutePath = System.Web.HttpContext.Current.Server.MapPath(element.Path);
            }

            return _absolutePath;
        }