StreamReader.ReadToEnd() returning an empty string

后端 未结 3 514
一向
一向 2020-12-17 18:00

I have a method

private static String DecompressAndDecode(byte[] data)
{
   GZipStream decompressor = new GZipStream(new MemoryStream(data), CompressionMode.         


        
3条回答
  •  情深已故
    2020-12-17 18:28

    Create your own custom function. It'll take the path as a parameter:

        static string read(string path)
        {
            StreamReader sr = new StreamReader(@path); 
            string txt = "";
            while (!sr.EndOfStream) {
                txt += sr.ReadLine() + "\n";
            }
            sr.Close();
            return txt;
        }
    

    Then call it instead of the call to ReadToEnd(). I tested it, and it worked.

提交回复
热议问题