Convert String in file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
Hi,


Ursula said:
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) );
 
Back
Top