On Sat, 24 Apr 2004 20:00:49 +0200, "Armin Zingler"
[quoted text, click to view] <az.nospam@freenet.de> wrote:
><les> schrieb
>> Now I'm really confused....I thought you were telling me I need to
>> convert the streamreader to a string before it can be passed to
>> the getbytes method.
>>
>> Is it possible you could show me how to modify the code? I'm quite
>> lost here
>
>I don't know what's your intention. You wanted to get the bytes from a
>stream in a certain encoding, right?
Yes but getting the following error:
BC30518: Overload resolution failed because no accessible 'GetBytes'
can be called with these arguments:
Line 20: Dim d As Byte() =
System.Text.Encoding.ASCII.GetBytes(readStream)
<%@ Page Language="VB" debug="True"%>
<%@ import namespace="system.io"%>
<%@ Import Namespace="System.Text" %>
<%@ import namespace="system.xml"%>
<%@ import Namespace="System.Net" %>
<%@ import Namespace="System.Web" %>
<Script Language="vb" runat="server">
Sub Page_Load(s as object, e as eventargs)
'Creates a streamreader from an xml file
Dim HttpWReq As HttpWebRequest =
CType(WebRequest.Create("http://server/datafile.xml"), HttpWebRequest)
Dim HttpWResp As HttpWebResponse = CType(HttpWReq.GetResponse(),
HttpWebResponse)
Dim receiveStream As Stream = HttpWResp.GetResponseStream()
Dim encode As Encoding =
system.Text.Encoding.GetEncoding("ISO-8859-1")
Dim readStream As New StreamReader(receiveStream, encode)
'post readstream to target server
Dim web As New System.Net.WebClient()
web.Headers.Add("Content-Type", "text/xml")
Dim d As Byte() = System.Text.Encoding.ASCII.GetBytes(readStream)
Dim res As Byte() = web.UploadData("http://targetserver/postpage",
"POST", d)
Console.Write(System.Text.Encoding.ASCII.GetString(res))
response.write (System.Text.Encoding.ASCII.GetString(res))
readStream.Close()
HttpWResp.Close()
End Sub
</script>