Skip to content

Commit

Permalink
improve resource management in FtpClient.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
Yousef-Majidi committed Oct 15, 2023
1 parent da641a0 commit fe2c077
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Src/CrispyWaffle.Utils/Communications/FtpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,10 @@ private bool ExistsInternal(string path)
request.ReadWriteTimeout = 90000;
request.UsePassive = true;

var response = (FtpWebResponse)request.GetResponse();
var responseStream = response.GetResponseStream();

using (var reader = new StreamReader(responseStream))
using var response = (FtpWebResponse)request.GetResponse();
using (var responseStream = response.GetResponseStream())
{
using var reader = new StreamReader(responseStream);
while (!reader.EndOfStream)
{
_files.Enqueue(reader.ReadLine());
Expand Down

0 comments on commit fe2c077

Please sign in to comment.