fix:error!the stearm dispose

This commit is contained in:
Kimdiego2098
2023-09-05 08:57:42 +08:00
parent 923b8bca31
commit a6d99fe227

View File

@@ -113,8 +113,9 @@ public class HardwareInfoService : ISingleton
try
{
var url = "http://myip.ipip.net";
var stream = await new HttpClient().GetStreamAsync(url);
var streamReader = new StreamReader(stream, Encoding.UTF8);
using var httpClient = new HttpClient();
using var stream = await httpClient.GetStreamAsync(url);
using var streamReader = new StreamReader(stream, Encoding.UTF8);
var html = streamReader.ReadToEnd();
return html.Replace("当前 IP", "").Replace("来自于:", "");
}