你可以先下载一个小工具,http://www.cnblogs.com/insus/articles/1999497.html
实例演示。
xxx.aspx代码:
View Code
<asp:FileUpload ID="FileUpload1" runat="server" Width="300" />
<asp:Button ID="Button1" runat="server"
Text="输出二进制" onclick="Button1_Click" /><br />
<asp:TextBox ID="txtbinary" runat="server" TextMode="MultiLine" Width="600" Height="500"></asp:TextBox>
<asp:Button ID="Button1" runat="server"
Text="输出二进制" onclick="Button1_Click" /><br />
<asp:TextBox ID="txtbinary" runat="server" TextMode="MultiLine" Width="600" Height="500"></asp:TextBox>
xxx.aspx.cs:
View Code
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Insus.NET;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
//实例化数据流转二进制Utility类别
InsusBinaryUtility objInsusBinaryUtility = new InsusBinaryUtility();
this.txtbinary.Text = objInsusBinaryUtility.StreamToBinary(this.FileUpload1.PostedFile.InputStream);
}
}
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Insus.NET;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
//实例化数据流转二进制Utility类别
InsusBinaryUtility objInsusBinaryUtility = new InsusBinaryUtility();
this.txtbinary.Text = objInsusBinaryUtility.StreamToBinary(this.FileUpload1.PostedFile.InputStream);
}
}
执行结果: