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

你可以先下载一个小工具,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>

 

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);
    }
}

 

执行结果:

 

posted @ 2011-03-30 10:26  Insus.NET  阅读(3263)  评论(1编辑  收藏  举报