<!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>
<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>
</HEAD>
<BODY lang=EN-US vLink=purple link=blue>
<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><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </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><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </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><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </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> mapguide-users-bounces@lists.osgeo.org
[mailto:mapguide-users-bounces@lists.osgeo.org] <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></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 -->…
this sequence tends 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"></SPAN></FONT> </P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">
// 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">
// 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">
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">
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">
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> </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>
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 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> </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'">
<FONT color=#2b91af><SPAN style="COLOR: #2b91af">String</SPAN></FONT>
mapDefinition = <FONT color=#a31515><SPAN style="COLOR: #a31515">"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'">
<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 defanghtml_style="margin-left:.5in"><FONT face="Courier New" size=2><SPAN
defanghtml_style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">
<FONT color=#2b91af><SPAN style="COLOR: #2b91af">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'">
<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
face="Courier New" size=2><SPAN
defanghtml_style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">
</SPAN></FONT><BR><FONT face="Courier New" size=2><SPAN
defanghtml_style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">
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> </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 style="BACKGROUND-COLOR: #ffffff">
<P align=center><FONT style="BACKGROUND-COLOR: #ffffff">This message has been
scanned for viruses by </FONT><A
href="http://bluepages.wsatkins.co.uk/?6875772"><FONT
style="BACKGROUND-COLOR: #ffffff"
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><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> </CENTER></P>
</body></HTML>