<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
The only way around it, that I have found, is to copy/paste code like
this:<br>
<br>
System.IO.MemoryStream ms = new System.IO.MemoryStream();<br>
byte[] buf = new byte[8*1024];<br>
int read = 1;<br>
while(read != 0)<br>
{<br>
&nbsp;&nbsp;&nbsp; read = <font face="Courier New" size="2"><span
 defanghtml_style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">mapByteRdr.Read(buf,
buf.length);<br>
&nbsp; ms.Write(buf, 0, read);<br>
</span></font>}<br>
<br>
//ms now contains the stream<br>
<br>
<pre class="moz-signature" cols="72">Regards, Kenneth, GEOGRAF A/S
</pre>
<br>
<br>
Campbell, Keith A skrev:
<blockquote
 cite="mid:2D5D8AC034A54041A6B2AE1C9148CC3106B22A2B@SGBBMA2102.wsatkins.com"
 type="cite">
  <title>ByteReader Problem</title>
  <meta http-equiv="Content-Type" content="text/html; ">
  <meta content="MSHTML 6.00.2900.3059" name="GENERATOR">
  <style> @font-face {
        font-family: Tahoma;
}
@font-face {
        font-family: Webdings;
}
@page Section1 {size: 8.5in 11.0in; margin: 1.0in 1.25in 1.0in 1.25in; }
P.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"
}
LI.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"
}
DIV.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"
}
A:link {
        COLOR: blue; TEXT-DECORATION: underline
}
SPAN.MsoHyperlink {
        COLOR: blue; TEXT-DECORATION: underline
}
A:visited {
        COLOR: purple; TEXT-DECORATION: underline
}
SPAN.MsoHyperlinkFollowed {
        COLOR: purple; TEXT-DECORATION: underline
}
P {
        FONT-SIZE: 12pt; MARGIN-LEFT: 0in; MARGIN-RIGHT: 0in; FONT-FAMILY: "Times New Roman"
}
SPAN.EmailStyle18 {
        COLOR: navy; FONT-FAMILY: Arial
}
DIV.Section1 {
        page: Section1
}
  </style>
  <div dir="ltr" align="left"><span class="210130015-31082007"><font
 color="#0000ff" face="Arial" size="2">Thanks Dennis.</font></span></div>
  <div dir="ltr" align="left"><span class="210130015-31082007"></span>&nbsp;</div>
  <div dir="ltr" align="left"><span class="210130015-31082007"><font
 color="#0000ff" face="Arial" size="2">I've tried this, but I'm only
getting 8192 bytes read into the byte buffer. This seems to be the
problem mentioned by Kenneth. The Read method doesn't seem to allow the
start location for the read to be set, so looping until the entire
content of the Resource is read into the buffer doesn't seem to be an
option.</font></span></div>
  <div dir="ltr" align="left"><span class="210130015-31082007"></span>&nbsp;</div>
  <div dir="ltr" align="left"><span class="210130015-31082007"><font
 color="#0000ff" face="Arial" size="2">Presumably somebody must have
found a way around this.</font></span></div>
  <div dir="ltr" align="left"><span class="210130015-31082007"></span>&nbsp;</div>
  <div dir="ltr" align="left"><span class="210130015-31082007"><font
 color="#0000ff" face="Arial" size="2">Keith</font></span></div>
  <br>
  <div class="OutlookMessageHeader" dir="ltr" align="left" lang="en-us">
  <hr tabindex="-1"><font face="Tahoma" size="2"><b>From:</b>
<a class="moz-txt-link-abbreviated" href="mailto:mapguide-users-bounces@lists.osgeo.org">mapguide-users-bounces@lists.osgeo.org</a>
[<a class="moz-txt-link-freetext" href="mailto:mapguide-users-bounces@lists.osgeo.org">mailto:mapguide-users-bounces@lists.osgeo.org</a>] <b>On Behalf Of </b>Jonio,
Dennis (Aviation)<br>
  <b>Sent:</b> 31 August 2007 14:05<br>
  <b>To:</b> MapGuide Users Mail List<br>
  <b>Subject:</b> RE: [mapguide-users] ByteReader Problem<br>
  </font><br>
  </div>
  <div class="Section1">
  <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span
 style="font-size: 10pt; color: navy; font-family: Arial;"><!-- Converted from text/rtf format -->&#8230;
this sequence tends to work &nbsp;&nbsp;&nbsp;&nbsp;</span></font></p>
  <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span
 style="font-size: 10pt; color: navy; font-family: Arial;"></span></font>&nbsp;</p>
  <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span
 style="font-size: 10pt; color: navy; font-family: Arial;">&nbsp;&nbsp;&nbsp;&nbsp; // For
some reason the MgByteReader "disappears"</span></font></p>
  <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span
 style="font-size: 10pt; color: navy; font-family: Arial;">&nbsp;&nbsp;&nbsp;&nbsp; // This
seems to work ....</span></font></p>
  <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span
 style="font-size: 10pt; color: navy; font-family: Arial;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
long long_length = rs.GetResourceContent(resId).GetLength();</span></font></p>
  <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span
 style="font-size: 10pt; color: navy; font-family: Arial;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
byte[] byteBuffer = new byte[long_length];</span></font></p>
  <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span
 style="font-size: 10pt; color: navy; font-family: Arial;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
int numBytes = rs.GetResourceContent(resId).Read(byteBuffer,
(int)long_length);</span></font></p>
  <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span
 style="font-size: 10pt; color: navy; font-family: Arial;"></span></font>&nbsp;</p>
  <p class="MsoNormal" defanghtml_style="margin-left:.5in"><font
 face="Tahoma" size="2"><span
 style="font-size: 10pt; font-family: Tahoma;">-----Original
Message-----<br>
  <b><span style="font-weight: bold;">From:</span></b>
<a class="moz-txt-link-abbreviated" href="mailto:mapguide-users-bounces@lists.osgeo.org">mapguide-users-bounces@lists.osgeo.org</a>
[<a class="moz-txt-link-freetext" href="mailto:mapguide-users-bounces@lists.osgeo.org">mailto:mapguide-users-bounces@lists.osgeo.org</a>] <b><span
 style="font-weight: bold;">On Behalf Of </span></b>Campbell, Keith A<br>
  <b><span style="font-weight: bold;">Sent:</span></b> </span></font><font
 face="Tahoma" size="2"><span
 style="font-size: 10pt; font-family: Tahoma;">Friday, August 31, 2007</span></font><font
 face="Tahoma" size="2"><span
 style="font-size: 10pt; font-family: Tahoma;"> </span></font><font
 face="Tahoma" size="2"><span
 style="font-size: 10pt; font-family: Tahoma;">7:10 AM</span></font><font
 face="Tahoma" size="2"><span
 style="font-size: 10pt; font-family: Tahoma;"><br>
  <b><span style="font-weight: bold;">To:</span></b> MapGuide Users
Mail List<br>
  <b><span style="font-weight: bold;">Subject:</span></b>
[mapguide-users] ByteReader Problem</span></font></p>
  <p class="MsoNormal" defanghtml_style="margin-left:.5in"><font
 face="Times New Roman" size="3"><span style="font-size: 12pt;"></span></font>&nbsp;</p>
  <p defanghtml_style="margin-left:.5in"><font face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">I am trying to alter a
map definition through the API and cannot get the contents of the
MgByteReader in string format. Here's the code:-</span></font></p>
  <p defanghtml_style="margin-left:.5in"><font face="Courier New"
 size="2"><span
 defanghtml_style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <font color="#2b91af"><span style="color: rgb(43, 145, 175);">String</span></font>
mapDefinition = <font color="#a31515"><span
 style="color: rgb(163, 21, 21);">"Library://My Folder/Maps/My
Map.MapDefinition"</span></font>;</span></font> <br>
  <font face="Courier New" size="2"><span
 defanghtml_style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <font color="#2b91af"><span style="color: rgb(43, 145, 175);">MgResourceIdentifier</span></font>
MapResID = <font color="blue"><span style="color: blue;">new</span></font>
  <font color="#2b91af"><span style="color: rgb(43, 145, 175);">MgResourceIdentifier</span></font>(mapDefinition);</span></font>
  </p>
  <p defanghtml_style="margin-left:.5in"><font face="Courier New"
 size="2"><span
 defanghtml_style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <font color="#2b91af"><span style="color: rgb(43, 145, 175);">MgByteReader</span></font>
mapByteRdr = res.GetResourceContent(MapResID);//res is instantiated
Resource Service.</span></font> </p>
  <p defanghtml_style="margin-left:.5in"><font face="Courier New"
 size="2"><span
 defanghtml_style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <font color="#2b91af"><span style="color: rgb(43, 145, 175);">XmlDocument</span></font>
doc = <font color="blue"><span style="color: blue;">new</span></font> <font
 color="#2b91af"><span style="color: rgb(43, 145, 175);">XmlDocument</span></font>();</span></font>
  <br>
  <font face="Courier New" size="2"><span
 defanghtml_style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  </span></font><br>
  <font face="Courier New" size="2"><span
 defanghtml_style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
doc.LoadXml(mapByteRdr.ToString());</span></font> </p>
  <p defanghtml_style="margin-left:.5in"><font face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">LoadXML fails with an
error ' Root element is missing'. I can copy the contents of</span></font>
  <font face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">mapByteRdr from Visual
Studio at runtime and it contains properly formatted XML for the map
definition. If I use the ToFile() method, the resultant file is empty.
I cannot see why these two methods do not return the xml string in the
reader. Any help is welcome.</span></font></p>
  <p defanghtml_style="margin-left:.5in"><font face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">Cheers,</span></font> </p>
  <p defanghtml_style="margin-left:.5in"><font face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">Keith</span></font> </p>
  <p class="MsoNormal"
 defanghtml_style="margin-right:0in;margin-bottom:12.0pt;margin-left:
.5in"><font
 face="Times New Roman" size="3"><span style="font-size: 12pt;"></span></font>&nbsp;</p>
  <p class="MsoNormal"
 defanghtml_style="margin-left:.5in;text-align:center" align="center"><b><font
 face="Arial" size="2"><span
 style="font-weight: bold; font-size: 10pt; font-family: Arial;">This
email and any attached files are confidential and copyright protected.
If you are not the addressee, any dissemination of this communication
is strictly prohibited. Unless otherwise expressly agreed in writing,
nothing stated in this communication shall be legally binding.</span></font></b>
  </p>
  <p defanghtml_style="margin-left:.5in;text-align:center"
 align="center"><font face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">The ultimate parent
company of the Atkins Group is WS Atkins plc. Registered in </span></font><font
 face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">England</span></font><font
 face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;"> No. 1885586. Registered
Office Woodcote Grove, </span></font><font face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">Ashley Road</span></font><font
 face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">, Epsom, </span></font><font
 face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">Surrey</span></font><font
 face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;"> KT18 5BW.</span></font> </p>
  <p defanghtml_style="margin-left:.5in;text-align:center"
 align="center"><font color="green" face="Webdings" size="5"><span
 style="font-size: 18pt; color: green; font-family: Webdings;">P</span></font>
  <b><font color="green" face="Arial" size="2"><span
 style="font-weight: bold; font-size: 10pt; color: green; font-family: Arial;">Consider
the environment. Please don't print this e-mail unless you really need
to.</span></font></b> </p>
  <div>
  <div class="MsoNormal"
 defanghtml_style="margin-left:.5in;text-align:center" align="center"><font
 face="Times New Roman" size="3"><span style="font-size: 12pt;">
  <hr align="center" size="2" width="100%"></span></font></div>
  <p class="MsoNormal" defanghtml_style="margin-left:.5in"><font
 face="Times New Roman" size="3"><span style="font-size: 12pt;">E-mails
are automatically scanned for viruses using McAfee. </span></font></p>
  </div>
  </div>
  <br>
  <br>
  <font style="background-color: rgb(255, 255, 255);">
  <p align="center"><font style="background-color: rgb(255, 255, 255);">This
message has been scanned for viruses by </font><a
 moz-do-not-send="true" href="http://bluepages.wsatkins.co.uk/?6875772"><font
 style="background-color: rgb(255, 255, 255);" color="#000000">MailControl</font></a></p>
  </font><br>
  <br>
  <center><font face="Arial, Helvetica, sans-serif" size="2"><b>This
email and any attached files are confidential and copyright protected.
If you are not the addressee, any dissemination of this communication
is strictly prohibited. Unless otherwise expressly agreed in writing,
nothing stated in this communication shall be legally binding.</b></font>
  <p><font face="Arial, Helvetica, sans-serif" size="2">The ultimate
parent company of the Atkins Group is WS Atkins plc. Registered in
England No. 1885586. Registered Office Woodcote Grove, Ashley Road,
Epsom, Surrey KT18 5BW.</font> </p>
  <p><font color="green" face="Webdings" size="5">P</font> <font
 color="green" face="Arial, Helvetica, sans-serif" size="2"><b>Consider
the environment. Please don't print this e-mail unless you really need
to.</b></font> </p>
  </center>
  <pre wrap="">
<hr size="4" width="90%">
_______________________________________________
mapguide-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:mapguide-users@lists.osgeo.org">mapguide-users@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/mapguide-users">http://lists.osgeo.org/mailman/listinfo/mapguide-users</a>
  </pre>
</blockquote>
</body>
</html>