Hello,
Is there an easy way to convert a string to a stream?
Thanks 7 97969
I found this...
Stream stream = new
MemoryStream(System.Text.ASCIIEncoding.GetBytes(pr intbuffer));
but when I compile, it gives me this...
An object reference is required for the nonstatic field, method, or property
'System.Text.Encoding.GetBytes(string)'
What does this mean?
Thanks for any help...
"Randy" <te**@temp.com> wrote in message
news:u4**************@tk2msftngp13.phx.gbl... Hello, Is there an easy way to convert a string to a stream? Thanks
Randy <te**@temp.com> wrote: Is there an easy way to convert a string to a stream?
Does System.IO.StringReader does what you want? If not, you could use
an Encoding to get the bytes from the string, then
System.IO.MemoryStream to build a stream from those bytes.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Hi Randy?
What you mean with that?
The best I can think of would be like
MemoryStream mstream = new MemoryStream( BitConverter.GetBytes(
string_var) );
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Randy" <te**@temp.com> wrote in message
news:u4**************@tk2msftngp13.phx.gbl... Hello, Is there an easy way to convert a string to a stream? Thanks
StringReader seems to work great! Thanks for your help...
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om... Randy <te**@temp.com> wrote: Is there an easy way to convert a string to a stream?
Does System.IO.StringReader does what you want? If not, you could use an Encoding to get the bytes from the string, then System.IO.MemoryStream to build a stream from those bytes.
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
Hi Randy,
You are missing the ASCII property form ASCIIEncoding:
System.Text.ASCIIEncoding.ASCII.GetBytes("test");
instead of:
System.Text.ASCIIEncoding.GetBytes(printbuffer)
BTW, I posted before an incorrect post, BitConverter.GetBytes() does not
have an overload for string , please ignore it.
Cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Randy" <te**@temp.com> wrote in message
news:eA**************@TK2MSFTNGP11.phx.gbl... I found this... Stream stream = new MemoryStream(System.Text.ASCIIEncoding.GetBytes(pr intbuffer)); but when I compile, it gives me this... An object reference is required for the nonstatic field, method, or
property 'System.Text.Encoding.GetBytes(string)'
What does this mean? Thanks for any help...
"Randy" <te**@temp.com> wrote in message news:u4**************@tk2msftngp13.phx.gbl... Hello, Is there an easy way to convert a string to a stream? Thanks
Oh yeah...thanks for the info. I see now...
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:u4**************@TK2MSFTNGP09.phx.gbl...
Hi Randy,
You are missing the ASCII property form ASCIIEncoding: System.Text.ASCIIEncoding.ASCII.GetBytes("test"); instead of: System.Text.ASCIIEncoding.GetBytes(printbuffer)
BTW, I posted before an incorrect post, BitConverter.GetBytes() does not have an overload for string , please ignore it.
Cheers,
-- Ignacio Machin, ignacio.machin AT dot.state.fl.us Florida Department Of Transportation
"Randy" <te**@temp.com> wrote in message news:eA**************@TK2MSFTNGP11.phx.gbl... I found this... Stream stream = new MemoryStream(System.Text.ASCIIEncoding.GetBytes(pr intbuffer)); but when I compile, it gives me this... An object reference is required for the nonstatic field, method, or property 'System.Text.Encoding.GetBytes(string)'
What does this mean? Thanks for any help...
"Randy" <te**@temp.com> wrote in message news:u4**************@tk2msftngp13.phx.gbl... Hello, Is there an easy way to convert a string to a stream? Thanks
<"Ignacio Machin \( .NET/ C# MVP \)" <ignacio.machin AT
dot.state.fl.us>> wrote: You are missing the ASCII property form ASCIIEncoding:
Note that it's actually a property of Encoding, not ASCIIEncoding -
it's just visible through ASCIIEncoding as well, of course. I
personally prefer to read:
Encoding ascii = Encoding.ASCII;
rather than
Encoding ascii = ASCIIEncoding.ASCII;
- the latter gives the impression that the property is a member of the
ASCIIEncoding class.
(Obviously the same goes for the other built-in encodings.)
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Nathan |
last post by:
Is there a way to convert a string to a CipherMessage? I am calling a
function that decrypts a CipherMessage and returns the value. The only
problem is when I want to use an encrypted value stored...
|
by: JM |
last post by:
Hi,
If you change the same string stream to a new string, why is it that
you have to .clear() it before using it? If I don't I get garbage.
Thanks,
Jason
ex.
|
by: TT (Tom Tempelaere) |
last post by:
Hey there,
I need a string stream, but I can't find one in .NET. I thought StringWriter
would derive from Stream, alas it doesn't do so.
Which leads me to my next question: What is the purpose...
|
by: Petr Jakes |
last post by:
Hi,
I am trying to convert string to the "escaped string".
example: from "0xf" I need "\0xf"
I am able to do it like:
a="0xf"
escaped_a=("\%s" % a ).decode("string_escape")
But it looks a...
|
by: Paul Aspinall |
last post by:
Hi
I want to send an ASCII character string / stream to an IP address.
I basically have 6 barcode printers, and a web interface.
Depending on what is entered on the web page, will determine...
|
by: Ursula |
last post by:
Is it possible to convert a string in a file. The problem is this:
I have an object string that is a file xml and I want to pass to Deserialize
function, but Deserialize function expect an object...
|
by: ad |
last post by:
I have a Steam, it read from a text file.
How can I convert this Stream to a String?
|
by: Brad |
last post by:
I am trying to convert an XML Stream received from a web api call into
a DataSet to use in the rest of the app. The issue I am running into
is that it will not convert the stream to a dataset and...
|
by: Peter |
last post by:
Trying to convert string to byte array.
the following code returns byte array of {107, 62, 194, 139, 64}
how can I convert this string to a byte array of {107, 62, 139, 65}
...
|
by: engteng |
last post by:
How do I convert string to numeric in VB.NET 2003 ?
Example convert P50001 to 50001 or 50001P to 50001 but if P is in middle
then not convert.
Regards,
Tee
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |