私のasp mvc 3アプリケーションには、ユーザーが特定のファイルをダウンロードできるようにするアクションがあります。
コードは次のとおりです。
public FilePathResult DownloadFile(string fileName)
{
try
{
string uploadsDocumentPath = System.Configuration.ConfigurationManager.AppSettings["uploadsDocumentPath"].ToString();
string ext = Path.GetExtension(fileName).ToLower();
Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(ext); // henter info fra windows registry
if (regKey != null && regKey.GetValue("Content Type") != null)
{
mimeType = regKey.GetValue("Content Type").ToString();
}
return File(uploadsDocumentPath + fileName, mimeType, fileName);
}
catch (Exception)
{
throw;
}
}
サイズが 150MB 未満のファイルのみをダウンロードできるようにしたいと考えています。しかし、このタイプのファイルのサイズを計算する方法が見つかりません。
何か案は ?