By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,610 Members | 1,957 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,610 IT Pros & Developers. It's quick & easy.

Convert String in file

P: n/a
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 of FileStream type and
the mode access.
There is a function Convert.ChangeType(object value, Type conversionType),
but I cant write for example:
Convert.ChangeType(mystring, FileStream);
CAN YOU HELP ME????? thanks
Mar 23 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi,

Are you sure that you need a FileStream instnace and not a Stream one?

If you can use a Stream instance what you can do is decorate the string as a
MemoryStream and pass it to the Deserialize method
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Ursula" <Ur****@discussions.microsoft.com> wrote in message
news:FF**********************************@microsof t.com...
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 of FileStream type
and
the mode access.
There is a function Convert.ChangeType(object value, Type conversionType),
but I cant write for example:
Convert.ChangeType(mystring, FileStream);
CAN YOU HELP ME????? thanks

Mar 23 '06 #2

P: n/a
Is a possible solution!But how I can do this?
How I can convert string in a Stream type?

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

Are you sure that you need a FileStream instnace and not a Stream one?

If you can use a Stream instance what you can do is decorate the string as a
MemoryStream and pass it to the Deserialize method
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Ursula" <Ur****@discussions.microsoft.com> wrote in message
news:FF**********************************@microsof t.com...
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 of FileStream type
and
the mode access.
There is a function Convert.ChangeType(object value, Type conversionType),
but I cant write for example:
Convert.ChangeType(mystring, FileStream);
CAN YOU HELP ME????? thanks


Mar 23 '06 #3

P: n/a
Hi,
"Ursula" <Ur****@discussions.microsoft.com> wrote in message
news:8B**********************************@microsof t.com...
Is a possible solution!But how I can do this?
How I can convert string in a Stream type?


You do not convert it, you just initialize a new MemoryStream with the
content of the string

Take a look at the constructor.

From memory I think this is the way to go:

new MemoryStream( Encoding.ASCII.GetBytes( your_string) );

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Mar 23 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.