上传
/// <summary>
/// 上传附件到数据库
/// </summary>
/// <param name="file"></param>
/// <returns></returns>
public void FileUpload(HttpPostedFile file)
{
try
{
Stream objFile;
objFile = file.InputStream;
BinaryReader objReader = new BinaryReader(objFile);
//读取文件内容
byte[] byteFile = objReader.ReadBytes((int)objFile.Length);
//文件扩展名
string strExtent = file.FileName.Substring(file.FileName.LastIndexOf("."));
}
catch (Exception ex)
{
throw;
}
}
下载
byte[] file = FileExport(AnnexID, out fnam);
if (file != null)
{
Response.ContentType = fnam.Substring(fnam.LastIndexOf("."));
Response.AddHeader("Content-Disposition", "attachment; filename=" + fnam);
Response.BinaryWrite(file);
Response.Flush();
Response.End();
}