首页 > 代码库 > FileUpload转换为字节
FileUpload转换为字节
//FileStream _fs = new FileStream(this.FileUpload1.FileName, FileMode.Open);
byte[] iBytes = new byte[this.FileUpload1.FileContent.Length];
BinaryReader _br = new BinaryReader(this.FileUpload1.FileContent);
iBytes = _br.ReadBytes(Convert.ToInt32(this.FileUpload1.FileContent.Length));
//_fs.Close();
string T_number = DateTime.Now.ToString().Replace("/", "").Replace(":", "").Replace(" ", "").Replace("-", "").Replace(".", "");
string T_message = this.TextBox1.Text.ToString().Trim();
DateTime T_releasetime = DateTime.Now;
if(_db.CreateReleases(T_number, T_message, iBytes, "NULL", T_releasetime))
{
Response.Redirect("~/", true);
}
else
{
Response.Write("<script type=‘text/javascript‘>alert(‘创建信息过程出错,请重试!‘);</script>");
return;
}
FileUpload转换为字节