Beispiel #1
0
        /// <summary>
        /// Check the file extension to find the corrisponding mimetype
        /// </summary>
        /// <param name="fileName">Filename containing the extension part</param>
        /// <returns>Associated mimetype</returns>
        public static string GetMIMEType(string fileName)
        {
            string extension = Path.GetExtension(fileName).ToLowerInvariant();

            if (extension.Length > 0 &&
                MIMETypesDictionary.ContainsKey(extension.Remove(0, 1)))
            {
                return(MIMETypesDictionary[extension.Remove(0, 1)]);
            }
            return("unknown/unknown");
        }
        /// <summary>
        /// Gets the MIME type of the file.
        /// </summary>
        /// <param name="fileName">Name of the file.</param>
        /// <returns></returns>
        public static string GetMIMEType(string fileName)
        {
            //get file extension
            string extension = Path.GetExtension(fileName).ToLowerInvariant();

            if (extension.Length > 0 &&
                MIMETypesDictionary.ContainsKey(extension.Remove(0, 1)))
            {
                return(MIMETypesDictionary[extension.Remove(0, 1)]);
            }
            return("application/octet-stream");
        }
Beispiel #3
0
        public static string GetContentType(string extenstion, bool download)
        {
            string lower = extenstion.ToLower().TrimStart('.');

            //Not to download the file, and we can process the file, let us process it.
            if (!download && MIMETypesDictionary.ContainsKey(lower))
            {
                Console.WriteLine(extenstion);
                return(MIMETypesDictionary[lower]);
            }
            return("application/octet-stream");
        }
        // Ziskanie pripony suboru, kvoli pridaniu do priloh a zisteniu, ci je tato pripona povolena
        public string GetMIMEType(string fileName)
        {
            //get file extension
            string extension = Path.GetExtension(fileName).ToLowerInvariant();

            if (blockedExtensions.Contains(extension))
            {
                return(null);
            }
            else if (extension.Length > 0 && MIMETypesDictionary.ContainsKey(extension.Remove(0, 1)))
            {
                return(MIMETypesDictionary[extension.Remove(0, 1)]);
            }
            return("unknown/unknown");
        }