473,327 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Help with System.IO.Stream



I need to pass my XML string as a stream to a method;

eg.

public SubmitResult ClickToRecord.Submit(
Stream stream,
ConflictResolutionPolicy policy,
out ProgramDetails[] programsInConflict
)

How can/should I pass this XML string via a stream to a method such as
this ??

Thanks,

Michael Hughes - Silverton, Oregon
http://wou.ath.cx/Trivia
http://wou.ath.cx/AmateurRadio
Nov 16 '05 #1
4 12786
A stream just contains a sequence of bytes, it has nothing to do with XML.
XML is simply the format of those bytes. Either you pass a stream to the
method or you must pass some class that interprets the XML such as an
XmlTextReader or XmlDocument.

"Michael H" <Mi*****@Strawberry.Gatorade.yum> wrote in message
news:4q********************************@4ax.com...


I need to pass my XML string as a stream to a method;

eg.

public SubmitResult ClickToRecord.Submit(
Stream stream,
ConflictResolutionPolicy policy,
out ProgramDetails[] programsInConflict
)

How can/should I pass this XML string via a stream to a method such as
this ??

Thanks,

Michael Hughes - Silverton, Oregon
http://wou.ath.cx/Trivia
http://wou.ath.cx/AmateurRadio

Nov 16 '05 #2
You would use Encoding.GetBytes() to convert your XML string to a byte array
then pass the byte array into the stream by using Stream.Write().

HTH

DalePres
MCAD, MCDBA, MCSE
"Michael H" <Mi*****@Strawberry.Gatorade.yum> wrote in message
news:4q********************************@4ax.com...


I need to pass my XML string as a stream to a method;

eg.

public SubmitResult ClickToRecord.Submit(
Stream stream,
ConflictResolutionPolicy policy,
out ProgramDetails[] programsInConflict
)

How can/should I pass this XML string via a stream to a method such as
this ??

Thanks,

Michael Hughes - Silverton, Oregon
http://wou.ath.cx/Trivia
http://wou.ath.cx/AmateurRadio

Nov 16 '05 #3
On Fri, 25 Feb 2005 21:43:44 -0800, "Peter Rilling"
<pe***@nospam.rilling.net> wrote:
A stream just contains a sequence of bytes, it has nothing to do with XML.
XML is simply the format of those bytes. Either you pass a stream to the
method or you must pass some class that interprets the XML such as an
XmlTextReader or XmlDocument.


I appreciate your input Peter, though I know this, but what I'm doing
now causes a CLR runtime error.

"Application has generated an exception that could not be handled."

"Process id=0xea0 (3744), Thread id=0x564 (1380)."

It could always be from the method call to Submit(....), this MCE2k5
isn't spitting out any details in the console window. I'll check that
next.

// xml is a string filled with xml.

byte[] byteArr;

System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();

byteArr = encoding.GetBytes(xml);

Microsoft.Windows.MediaCenter.ProgramDetails [] details;

System.IO.Stream sr = new System.IO.MemoryStream(byteArr);

ClickToRecord.Submit( sr,

Microsoft.Windows.MediaCenter.ClickToRecord.Confli ctResolutionPolicy.AllowConflict,
out details);

I was just having a brainfart earlier on how to start with a stream,
move the data to a byte array, then use the byte array to instantiate
a Stream object for passing to my Submit() method. Too much work is
frying my brain, eh?

Have a good weekend,

Michael Hughes - Silverton, Oregon
http://wou.ath.cx/Trivia
http://wou.ath.cx/AmateurRadio

Nov 16 '05 #4
On Fri, 25 Feb 2005 23:48:00 -0600, "DalePres"
<don-t-spa-m-me@lea-ve-me-a-lone--.com> wrote:
You would use Encoding.GetBytes() to convert your XML string to a byte array
then pass the byte array into the stream by using Stream.Write().

HTH

DalePres
MCAD, MCDBA, MCSE

Thanks for the input, DalePres.


Michael Hughes - Silverton, Oregon
http://wou.ath.cx/Trivia
http://wou.ath.cx/AmateurRadio

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

31
by: da Vinci | last post by:
OK, this has got to be a simple one and yet I cannot find the answer in my textbook. How can I get a simple pause after an output line, that simply waits for any key to be pressed to move on? ...
0
by: Henrik Nordgren | last post by:
Im trying to build a simple chat app... here is the code: server visual basic code:-------------------------------------------------------------------------------- Public Class ChatServer ...
8
by: MattP | last post by:
Ok, with the help of some examples found on the web and some minor modifications on our own, we have a simple and working encrypt and decrypt solution. It runs as a service, watches for files with...
15
by: Buck Rogers | last post by:
Hi guys! Task 1: Write a program which presents a menu with 5 options. The 5th option quits the program. Each option should execute a system command using system(). Below is my humble...
10
by: Alejandro Castañaza | last post by:
Hi. I'm writing a program, and I need to send confidential data through the network, so I decided to use encryption, using the System.Security.Cryptography namespace. I'm using the sockets...
4
by: Russ | last post by:
I am trying to convert this VB code to C#. Can someone give me a hand. The code is for exporting a crystal report to a PDF using a memory stream. Here is the VB: Dim s As...
0
by: Tony Archer | last post by:
Here's my problem... When I use this code to hit the site in question I'm redirected to another SSL login page. If processed successfully the page creates a cookie and then redirects you to the...
1
by: jens Jensen | last post by:
Hello , i'm calling a webservice generated with oracle webservice java tools. I'm not able to add a web reference to a .net client the usual way with visual studio 2005. I was therefore...
0
by: dba123 | last post by:
I'm trying to implement my own Virtual Path Provider class. http://msdn2.microsoft.com/en-us/library/system.web.hosting.virtualpathprovider.aspx ...
3
by: Simon Brooke | last post by:
As various people will have noticed, I've been having a lot of trouble with XSL lately. Brief history: I wrote myself an XML toolkit back in 2000, and it worked well enough for me, so it's been...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.