C#实现文件上传与下载功能实例

2019-12-30 14:51:48王冬梅
word"; break; case "zip": ContentType = "application/zip"; break; case "xls": ContentType = "application/vndms-excel"; break; case "gif": ContentType = "image/gif"; break; case "jpg": ContentType = "image/jpeg"; break; case "jpeg": ContentType = "image/jpeg"; break; case "wav": ContentType = "audio/wav"; break; case "mp3": ContentType = "audio/mpeg3"; break; case "mpg": ContentType = "video/mpeg"; break; case "mepg": ContentType = "video/mpeg"; break; case "rtf": ContentType = "application/rtf"; break; case "html": ContentType = "text/html"; break; case "htm": ContentType = "text/html"; break; case "txt": ContentType = "text/plain"; break; default: ContentType = "application/octet-stream"; break; } return ContentType; }

*如何获取现有文件的ContentType属性


/// <summary> 
/// 获取现有文件的ContentType属性 
/// </summary> 
/// <param name="filename"></param> 
/// <returns></returns> 
public string GetFileContentType(string filename) 
{ 
  string[] array = filenameSplit(''); 
  string result = stringEmpty; 
  string suffix = "" + array[arrayLength - 1]; 
  MicrosoftWinRegistryKey rg = MicrosoftWinRegistryClassesRootOpenSubKey(suffix); 
  object obj = rgGetValue("Content Type"); 
  result = obj != null ? objToString() : stringEmpty; 
  rgClose(); 
  return result; 
}  

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持ASPKU。


注:相关教程知识阅读请移步到c#教程频道。