Reputation: 1
I want to read the response from the URI and modify it by replacing all S's to X's and to return that string back to client. Below is my code, but replace is not working. I downloaded the "response" string to check and there are lots of S characters. Any idea why this is not working or how can I manipulate this ?
try
{
// open and read from the supplied URI
stream = webClient.OpenRead(uri);
reader = new StreamReader(stream);
response = reader.ReadToEnd();
response.Replace('S', 'X');
webClient.DownloadFile(uri, "C://Users//MyPC//Desktop//a.txt");
}
Thanks..
Upvotes: 0
Views: 467
Reputation: 446
you can use webClient.DownloadString(uri)
like this:
string str = webClient.DownloadString(uri).Replace('S', 'X');
File.WriteAllText(@"C://Users//MyPC//Desktop//a.txt", str);
Upvotes: 1