Hi Mano,
I made it work by adding the size before writing it, and it works.
but now I have another problem: I changed my program in tha way to
write the kml file in a doc1 in a function(this function returns doc1
as an object), when I want to zip it, the kmz file is different from
what I had with the privius metod(for some placemarks I don't have the
CDATA part.
I 'll be glad if someone can help me , I'm getting so confused.
the function is in my .aspx.vb file
Public Function GetKmlFile() As Object
Dim cnn As New
SqlConnection(ConfigurationManager.ConnectionStrings("....").ToString)
Dim cmm As New SqlCommand
cnn.Open()
cmm.CommandType = CommandType.StoredProcedure
cmm.CommandText = "......"
cmm.Connection = cnn
Dim parUtility As New SqlParameter("......", "......")
cmm.Parameters.Add(parUtility)
Dim sPath As String =
Request.Url.AbsoluteUri.Replace(Request.Url.AbsolutePath, "") +
Request.ApplicationPath & "......aspx"
Dim parUrl As New SqlParameter("@Url", sPath)
cmm.Parameters.Add(parUrl)
Dim result As XmlReader = cmm.ExecuteXmlReader()
result.Read()
Dim doc1 As MSXML2.DOMDocument30
Dim doc2 As MSXML2.DOMDocument30
Dim doc2Node As MSXML2.IXMLDOMNode
doc1 = New MSXML2.DOMDocument30
doc2 = New MSXML2.DOMDocument30
doc1.loadXML(result.ReadOuterXml())
doc2.load(Server.MapPath("KMLStylesDoc.XML"))
'Server.MapPath("KMLStylesDoc.XML")
If Not doc1.documentElement Is Nothing Then
For Each doc2Node In doc2.documentElement.childNodes
doc1.documentElement.insertBefore(doc2Node,
doc1.documentElement.firstChild)
'doc1.documentElement.appendChild(doc2Node)
Next
End If
Return doc1.xml.ToString
End Function
and in .aspx file I have:
Response.ContentType = "application/vnd.google-earth.kmz"
Response.AddHeader("Content-Disposition", "attachment;
filename=MeterData.kmz")
<kml xmlns="
http://earth.google.com/kml/2.2">
<Document>
<name>......</name>
<description>......</description>
.
.
.
</Document>
</kml>
<%
Dim bytes As Byte()
Dim enc As New UTF8Encoding
bytes = enc.GetBytes(GetKmlFile())
Dim memStream2 As IO.MemoryStream = New IO.MemoryStream()
Dim Zos As ZipOutputStream = New ZipOutputStream(memStream2)
Using (Zos)
Dim entry As ZipEntry
entry = New ZipEntry("MeterDetails.kml")
entry.Size = bytes.Length
Zos.SetLevel(9)
Zos.PutNextEntry(entry)
Zos.Write(bytes, 0, bytes.Length)
Zos.CloseEntry()
Zos.Close()
End Using
Response.Clear()
Response.BinaryWrite(memStream2.ToArray())
Response.End()
%>
it seams that GetKmlFile()return something different, if I cut the
html part after</kml> it just works fine(I can have the kml that I
want)!!??
> > Response.End()- Hide quoted text -
>
> - Show quoted text -