实例演示。

xxx.aspx代码:


如何把数据流转换为二进制字符串_asp.net如何把数据流转换为二进制字符串_数据_02View 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>


 

xxx.aspx.cs:


如何把数据流转换为二进制字符串_asp.net如何把数据流转换为二进制字符串_数据_02View 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);

    }

}


 

执行结果:

如何把数据流转换为二进制字符串_Stream_05