How do I use File.ReadAllBytes In chunks

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

    If the file is a text file you can use a TextReader:

       string location1 = textBox2.Text;
        string text  = String.Empty;
        using (TextReader reader = File.OpenText(location1 ))
        {
               do
               {
               string line = reader.ReadLine();
                   text+=line;
                }
                while(line!=null)
    
        }
    

提交回复
热议问题