Reading Sharepoint 2019 List with StreamReader.readtoend() returns empty string

Copper Contributor

I currently must extract data from Sharepoint List to XML.  It works fine when I'm reading data from a Sharepoint 2010 List.

Now, Sharepoint server will be migrated, and I have to test if current script will works with new version of Sharepoint. Unfortenately, the following code:

    response = request.GetResponse();
    string xmlData;    using (StreamReader sr = new StreamReader(response.GetResponseStream()))
    {        xmlData = sr.ReadToEnd();       sr.Close();
    }

returns empty string. I try to add position = 0, but it return error (can not use seek for this stream, or something approaching).

Trying

   

     string xmlData = "";using (StreamReader sr = new StreamReader(response.GetResponseStream()))
    {
        //xmlData = sr.ReadToEnd();
        while (!sr.EndOfStream)
        {            xmlData += sr.ReadLine() + "\n";
        }        sr.Close();
    }

will not work. In this case, in debug mode, the program not pass on while loop (as if the position of cursor was directly at end of Stream).

Is there any change regarding Sharepoint 2019 that need to be add on code ?

0 Replies