How do I use File.ReadAllBytes In chunks

后端 未结 5 1210
北恋
北恋 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:15

    Depending on the file structure, it might be easier for you to use a StreamReader which exposes a ReadLine method.

    using(var sr = new StreamReader(File.Open(textBox2.Text, FileMode.Open))
    {
        while (sr.Peek() >= 0) 
        {
            Console.WriteLine(sr.ReadLine());
         }
    }
    

提交回复
热议问题