469,317 Members | 1,884 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,317 developers. It's quick & easy.

Convert String in file

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
3 7519
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
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
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.

Similar topics

1 post views Thread by mevar81 | last post: by
2 posts views Thread by Mel WEaver | last post: by
12 posts views Thread by Brian Henry | last post: by
3 posts views Thread by GM | last post: by
7 posts views Thread by elliotng.ee | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.