<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">


<meta name=Generator content="Microsoft Word 10 (filtered)">
<title>ByteReader Problem</title>

<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Webdings;
        panose-1:5 3 1 2 1 5 9 6 7 3;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
p
        {margin-right:0in;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman";}
span.EmailStyle18
        {font-family:Arial;
        color:navy;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><!-- Converted from text/rtf format -->&#8230;
this sequence tends to work &nbsp;&nbsp;&nbsp;&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp; // For some reason the MgByteReader
&quot;disappears&quot;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp; // This seems to work ....</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&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 size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; byte[] byteBuffer = new byte[long_length];</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&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 size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma'>-----Original Message-----<br>
<b><span style='font-weight:bold'>From:</span></b> mapguide-users-bounces@lists.osgeo.org
[mailto:mapguide-users-bounces@lists.osgeo.org] <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 size=2 face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>Friday, August
 31, 2007</span></font><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma'> </span></font><font size=2 face=Tahoma><span
 style='font-size:10.0pt;font-family:Tahoma'>7:10 AM</span></font><font size=2
face=Tahoma><span style='font-size:10.0pt;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 style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>&nbsp;</span></font></p>

<p style='margin-left:.5in'><font size=2 face=Arial><span style='font-size:
10.0pt;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 style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font color="#2b91af"><span style='color:#2B91AF'>String</span></font>
mapDefinition = <font color="#a31515"><span style='color:#A31515'>&quot;Library://My
Folder/Maps/My Map.MapDefinition&quot;</span></font>;</span></font> <br>
<font size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font color="#2b91af"><span style='color:#2B91AF'>MgResourceIdentifier</span></font>
MapResID = <font color=blue><span style='color:blue'>new</span></font> <font
color="#2b91af"><span style='color:#2B91AF'>MgResourceIdentifier</span></font>(mapDefinition);</span></font>
</p>

<p style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font color="#2b91af"><span style='color:#2B91AF'>MgByteReader</span></font>
mapByteRdr = res.GetResourceContent(MapResID);//res is instantiated Resource
Service.</span></font> </p>

<p style='margin-left:.5in'><font size=2 face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font color="#2b91af"><span style='color:#2B91AF'>XmlDocument</span></font> doc
= <font color=blue><span style='color:blue'>new</span></font> <font
color="#2b91af"><span style='color:#2B91AF'>XmlDocument</span></font>();</span></font>
<br>
<font size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></font><br>
<font size=2 face="Courier New"><span style='font-size:10.0pt;font-family:"Courier New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
doc.LoadXml(mapByteRdr.ToString());</span></font> </p>

<p style='margin-left:.5in'><font size=2 face=Arial><span style='font-size:
10.0pt;font-family:Arial'>LoadXML fails with an error ' Root element is
missing'. I can copy the contents of</span></font> <font size=2 face=Arial><span
style='font-size:10.0pt;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 style='margin-left:.5in'><font size=2 face=Arial><span style='font-size:
10.0pt;font-family:Arial'>Cheers,</span></font> </p>

<p style='margin-left:.5in'><font size=2 face=Arial><span style='font-size:
10.0pt;font-family:Arial'>Keith</span></font> </p>

<p class=MsoNormal style='margin-right:0in;margin-bottom:12.0pt;margin-left:
.5in'><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>&nbsp;</span></font></p>

<p class=MsoNormal align=center style='margin-left:.5in;text-align:center'><b><font
size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial;font-weight:
bold'>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 style='margin-left:.5in;text-align:center'><font size=2
face=Arial><span style='font-size:10.0pt;font-family:Arial'>The ultimate parent
company of the Atkins Group is WS Atkins plc. Registered in </span></font><font
  size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>England</span></font><font
size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'> No.
1885586. Registered Office Woodcote Grove, </span></font><font size=2
  face=Arial><span style='font-size:10.0pt;font-family:Arial'>Ashley Road</span></font><font
size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>, Epsom, </span></font><font
 size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>Surrey</span></font><font
size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'> KT18 5BW.</span></font>
</p>

<p align=center style='margin-left:.5in;text-align:center'><font size=5
color=green face=Webdings><span style='font-size:18.0pt;font-family:Webdings;
color:green'>P</span></font> <b><font size=2 color=green face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:green;font-weight:bold'>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 style='margin-left:.5in;text-align:center'><font
size=3 face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=2 width="100%" align=center>

</span></font></div>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'>E-mails are automatically scanned for viruses using
McAfee. </span></font></p>

</div>

</div>

</body>

</html>