Cleaned up warnings in code

This commit is contained in:
Henry Asbridge 2022-06-23 15:50:26 +01:00
commit b4d28966c7
2 changed files with 14 additions and 11 deletions

View file

@ -5,13 +5,15 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
namespace LBPUnion.UnionPatcher.Communication; #pragma warning disable SYSLIB0014 // the FtpWebRequest is needed in this case
namespace LBPUnion.UnionPatcher.Communication;
public static class FTP public static class FTP
{ {
public static bool FileExists(string url, string user, string pass) public static bool FileExists(string url, string user, string pass)
{ {
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(url); FtpWebRequest request = (FtpWebRequest)WebRequest.Create(url);
request.Credentials = new NetworkCredential(user, pass); request.Credentials = new NetworkCredential(user, pass);
request.Method = WebRequestMethods.Ftp.GetDateTimestamp; request.Method = WebRequestMethods.Ftp.GetDateTimestamp;
@ -36,6 +38,7 @@ public static class FTP
public static string[] ListDirectory(string url, string user, string pass) public static string[] ListDirectory(string url, string user, string pass)
{ {
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(url); FtpWebRequest request = (FtpWebRequest)WebRequest.Create(url);
request.Credentials = new NetworkCredential(user, pass); request.Credentials = new NetworkCredential(user, pass);
request.Method = WebRequestMethods.Ftp.ListDirectory; request.Method = WebRequestMethods.Ftp.ListDirectory;
@ -53,7 +56,7 @@ public static class FTP
.Where(dir => !string.IsNullOrWhiteSpace(dir) && dir != "." && dir != "..") .Where(dir => !string.IsNullOrWhiteSpace(dir) && dir != "." && dir != "..")
.ToList(); .ToList();
foreach(string dir in dirs.ToArray()) foreach (string dir in dirs.ToArray())
{ {
Console.WriteLine($"/{dir}"); Console.WriteLine($"/{dir}");
} }

View file

@ -234,7 +234,7 @@ public class PS3MAPI
} }
} }
main_sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); main_sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
main_ipEndPoint = new IPEndPoint(Dns.GetHostByName(sServerIP).AddressList[0], Port); main_ipEndPoint = new IPEndPoint(Dns.GetHostAddresses(sServerIP)[0], Port);
try try
{ {
main_sock.Connect(main_ipEndPoint); main_sock.Connect(main_ipEndPoint);
@ -781,12 +781,12 @@ public class PS3MAPI
SetBinaryMode(false); SetBinaryMode(false);
} }
} }
catch (Exception e) catch
{ {
CloseDataSocket(); CloseDataSocket();
ReadResponse(); ReadResponse();
SetBinaryMode(false); SetBinaryMode(false);
throw e; throw;
} }
} }
} }
@ -847,12 +847,12 @@ public class PS3MAPI
SetBinaryMode(false); SetBinaryMode(false);
} }
} }
catch (Exception e) catch
{ {
CloseDataSocket(); CloseDataSocket();
ReadResponse(); ReadResponse();
SetBinaryMode(false); SetBinaryMode(false);
throw e; throw;
} }
} }
} }
@ -1094,7 +1094,7 @@ public class PS3MAPI
{ {
CloseDataSocket(); CloseDataSocket();
data_sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); data_sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
data_ipEndPoint = new IPEndPoint(Dns.GetHostByName(sServerIP).AddressList[0], iPort); data_ipEndPoint = new IPEndPoint(Dns.GetHostAddresses(sServerIP)[0], iPort);
data_sock.Connect(data_ipEndPoint); data_sock.Connect(data_ipEndPoint);
} }
catch (Exception e) catch (Exception e)