Max File Size Upload In ASP.Net

By default, the maximum file size to upload is 4MB. To increase it, simply add this section in web.config:

This will dictate the maximum size to be 5MB.

Advertisements

File MIME Type Using C#

string fileName = “C:\\somefile.vsd”;
string mimeType = “application/unknown”;
string ext = System.IO.Path.GetExtension(fileName).ToLower();
Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(ext);
if (regKey != null && regKey.GetValue(“Content Type”) != null)
{
mimeType = regKey.GetValue(“Content Type”).ToString();
}