Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do I get this into a string variable?
Message
 
À
12/05/2008 15:31:11
Mike Sue-Ping
Cambridge, Ontario, Canada
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01316145
Message ID:
01316506
Vues:
24
>>>Newbie question. I have the following snippet of C# code that writes the contents of "SearchResponse" to a file. How can I get the contents into a string variable instead?
>>>
>>
>>Try something like this:
>>
>>
>>XmlSerializer xmlizer = new XmlSerializer(typeof(SearchResponse));
>>StringWriter sw = new StringWriter();
>>xmlizer.Serialize(sw, iw.SearchResponse);
>>
>
>Hi Paul,
>
>Can you suggest how I can get the following into a string instead of a file?
>
>
>FileStream fs = new FileStream("c:/xmlresponse2.xml", FileMode.Create);
>fs.Write(m_searchresponse.Manifest[0].Content.Value, 0, m_searchresponse.Manifest[0].Content.Value.Length);
>fs.Close();
>
>

Maybe (assuming m_searchresponse.Manifest[0].Content.Value is a byte[]) :
string result = System.Text.Encoding.ASCII.GetString(m_searchresponse.Manifest[0].Content.Value);
-Paul

RCS Solutions, Inc.
Blog
Twitter
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform