How do I use File.ReadAllBytes In chunks

后端 未结 5 1208
北恋
北恋 2020-12-22 14:40

I am using this code

        string location1 = textBox2.Text;
        byte[] bytes = File.ReadAllBytes(location1);
        string text = (Convert.ToBase64S         


        
5条回答
  •  悲&欢浪女
    2020-12-22 15:21

    private void button1_Click(object sender, EventArgs e)
    {
        const int MAX_BUFFER = 2048;
        byte[] Buffer = new byte[MAX_BUFFER];
        int BytesRead;
        using (System.IO.FileStream fileStream = new FileStream(textBox2.Text, FileMode.Open, FileAccess.Read))
            while ((BytesRead = fileStream.Read(Buffer, 0, MAX_BUFFER)) != 0)
            {
                string text = (Convert.ToBase64String(Buffer));
                textBox1.Text = text;
    
            }
    }
    

提交回复
热议问题