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

%3CLINGO-SUB%20id%3D%22lingo-sub-1277647%22%20slang%3D%22fr-FR%22%3EReading%20Sharepoint%202019%20List%20with%20StreamReader.readtoend()%20returns%20empty%20string%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1277647%22%20slang%3D%22fr-FR%22%3E%3CP%3EI%20currently%20must%20extract%20data%20from%20Sharepoint%20List%20to%20XML.%26nbsp%3B%20It%20works%20fine%20when%20I'm%20reading%20data%20from%20a%20Sharepoint%202010%20List.%3C%2FP%3E%3CP%3ENow%2C%20Sharepoint%20server%20will%20be%20migrated%2C%20and%20I%20have%20to%20test%20if%20current%20script%20will%20work%20with%20new%20version%20of%20Sharepoint.%20Unfortenately%2C%20the%20following%20code%3A%3C%2FP%3E%3CPRE%3E%3CSPAN%20class%3D%22pln%22%3E%20%20%20%20response%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20request%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EGetResponse%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E()%3B%3C%2FSPAN%3E%0A%20%20%20%20%3CSPAN%20class%3D%22kwd%22%3Estring%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20xmlData%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20%20%20%20using%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EStreamReader%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20sr%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22kwd%22%3Enew%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22typ%22%3EStreamReader%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3Eresponse%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EGetResponseStream%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E()))%3C%2FSPAN%3E%0A%20%20%20%20%3CSPAN%20class%3D%22pun%22%3E%7B%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20%20%20%20%20%20%20%20xmlData%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20sr%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EReadToEnd%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E()%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20%20%20%20%20%20%20sr%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EClose%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E()%3B%3C%2FSPAN%3E%0A%20%20%20%20%3CSPAN%20class%3D%22pun%22%3E%7D%3C%2FSPAN%3E%3C%2FPRE%3E%3CP%3Eempty%20string%20returns.%20I%20try%20to%20add%20position%200%2C%20but%20it%20return%20error%20(can%20not%20use%20seek%20for%20this%20stream%2C%20or%20something%20approaching).%3C%2FP%3E%3CP%3ETrying%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CPRE%3E%3CSPAN%20class%3D%22pln%22%3E%20%20%20%20%20string%20xmlData%20%3D%20%22%22%3Busing%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EStreamReader%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20sr%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22kwd%22%3Enew%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22typ%22%3EStreamReader%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3Eresponse%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EGetResponseStream%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E()))%3C%2FSPAN%3E%0A%20%20%20%20%3CSPAN%20class%3D%22pun%22%3E%7B%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22com%22%3E%2F%2FxmlData%20%3D%20sr.ReadToEnd()%3B%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22kwd%22%3Ewhile%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pun%22%3E(!%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3Esr%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EEndOfStream%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E)%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22pun%22%3E%7B%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20%20%20%20%20%20%20%20%20%20%20%20xmlData%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%2B%3D%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20sr%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EReadLine%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E()%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pun%22%3E%2B%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22str%22%3E%22%5Cn%22%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3B%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22pun%22%3E%7D%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20%20%20%20%20%20%20%20sr%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EClose%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E()%3B%3C%2FSPAN%3E%0A%20%20%20%20%3CSPAN%20class%3D%22pun%22%3E%7D%3C%2FSPAN%3E%3C%2FPRE%3E%3CP%3Ewill%20not%20work.%20In%20this%20case%2C%20in%20debug%20mode%2C%20the%20program%20not%20pass%20on%20while%20loop%20(as%20if%20the%20position%20of%20cursor%20was%20directly%20at%20end%20of%20Stream).%3C%2FP%3E%3CP%3EIs%20there%20any%20change%20regarding%20Sharepoint%202019%20that%20need%20to%20be%20add%20on%20code%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1277647%22%20slang%3D%22fr-FR%22%3E%3CLINGO-LABEL%3Ewebresponse%20development%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharepoint%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Occasional Visitor

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
www.000webhost.com