<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>ByteReader Problem</TITLE>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.3059" name=GENERATOR></HEAD>
<BODY text=#000000 bgColor=#ffffff>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN 
class=757551811-03092007>Kenneth,</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN 
class=757551811-03092007></SPAN></FONT>&nbsp;</DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN 
class=757551811-03092007>If I run this code, it results in an endless loop 
because the </SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN 
class=757551811-03092007><FONT face="Times New Roman" color=#000000 
size=3>&nbsp;&nbsp;&nbsp; read = </FONT><FONT face="Courier New" size=2><SPAN 
defanghtml_style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><FONT 
color=#000000>mapByteRdr.Read(buf, buf.length);</FONT><BR>call reads the same 
data each time&nbsp;- the start point for each read is not 
advanced.</SPAN></FONT></SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN 
class=757551811-03092007><FONT face="Courier New" size=2><SPAN 
defanghtml_style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"></SPAN></FONT></SPAN></FONT>&nbsp;</DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN 
class=757551811-03092007><FONT face="Courier New" size=2><SPAN 
defanghtml_style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">Keith</SPAN></FONT></SPAN></FONT></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> mapguide-users-bounces@lists.osgeo.org 
[mailto:mapguide-users-bounces@lists.osgeo.org] <B>On Behalf Of </B>Kenneth, 
GEOGRAF A/S<BR><B>Sent:</B> 31 August 2007 17:14<BR><B>To:</B> MapGuide Users 
Mail List<BR><B>Subject:</B> Re: [mapguide-users] ByteReader 
Problem<BR></FONT><BR></DIV>
<DIV></DIV>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" defanghtml_cols="72">Regards, Kenneth, GEOGRAF A/S
</PRE><BR><BR>Campbell, Keith A skrev: 
<BLOCKQUOTE 
cite=mid:2D5D8AC034A54041A6B2AE1C9148CC3106B22A2B@SGBBMA2102.wsatkins.com 
type="cite">
  <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 face=Arial 
  color=#0000ff 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 face=Arial 
  color=#0000ff 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 face=Arial 
  color=#0000ff 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 face=Arial 
  color=#0000ff size=2>Keith</FONT></SPAN></DIV><BR>
  <DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
  <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 face=Arial color=navy 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 face=Arial color=navy size=2><SPAN 
  style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"></SPAN></FONT>&nbsp;</P>
  <P class=MsoNormal><FONT face=Arial color=navy 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 face=Arial color=navy 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 face=Arial color=navy 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 face=Arial color=navy 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 face=Arial color=navy 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 face=Arial color=navy 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 
  defanghtml_style="color: rgb(43, 145, 175);">String</SPAN></FONT> 
  mapDefinition = <FONT color=#a31515><SPAN 
  defanghtml_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 
  defanghtml_style="color: rgb(43, 145, 175);">MgResourceIdentifier</SPAN></FONT> 
  MapResID = <FONT color=blue><SPAN style="COLOR: blue">new</SPAN></FONT> <FONT 
  color=#2b91af><SPAN 
  defanghtml_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 
  defanghtml_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 
  defanghtml_style="color: rgb(43, 145, 175);">XmlDocument</SPAN></FONT> doc = 
  <FONT color=blue><SPAN style="COLOR: blue">new</SPAN></FONT> <FONT 
  color=#2b91af><SPAN 
  defanghtml_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:&#13;&#10;.5in"><FONT 
  face="Times New Roman" size=3><SPAN 
  style="FONT-SIZE: 12pt"></SPAN></FONT>&nbsp;</P>
  <P class="MsoNormal" align="center" 
  defanghtml_style="margin-left:.5in;text-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 align="center" defanghtml_style="margin-left:.5in;text-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 align="center" defanghtml_style="margin-left:.5in;text-align:center"><FONT 
  face=Webdings color=green size=5><SPAN 
  style="FONT-SIZE: 18pt; COLOR: green; FONT-FAMILY: Webdings">P</SPAN></FONT> 
  <B><FONT face=Arial color=green 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" align="center" 
  defanghtml_style="margin-left:.5in;text-align:center"><FONT 
  face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt">
  <HR align=center width="100%" SIZE=2>
  </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 
  defanghtml_style="background-color: rgb(255, 255, 255);">
  <P align=center><FONT 
  defanghtml_style="background-color: rgb(255, 255, 255);">This message has been 
  scanned for viruses by </FONT><A 
  href="http://bluepages.wsatkins.co.uk/?6875772" 
  defanghtml_moz-do-not-send="true"><FONT color="#000000" 
  defanghtml_style="background-color: rgb(255, 255, 255);">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 face=Webdings color=green size=5>P</FONT> <FONT 
  face="Arial, Helvetica, sans-serif" color=green 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 width="90%" SIZE=4>
_______________________________________________
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>