You can try using the FtpWebRequest method.
Sample:
public static byte[] DownloadFile(string url, string filePath, string user, string password) { var ftpServerUrl = string.Concat(url, filePath); var request = (FtpWebRequest) WebRequest.Create(ftpServerUrl); request.Method = WebRequestMethods.Ftp.DownloadFile; request.Credentials = new NetworkCredential(user,password); using (var response = (FtpWebResponse) request.GetResponse()) using (var responseStream = response.GetResponseStream()) using (var memoryStream = new MemoryStream()) { responseStream?.CopyTo(memoryStream); return memoryStream.ToArray(); } }
Remember that ftpServerUrl must be a valid uri path containing the file path. e.g. ftpServerUrl = "ftp://ftp.server/targetfile.txt"
source share