C# FtpWebRequest fails

391 views Asked by At

This code fails. Any help please. Thanks

using System.net
using System.IO

string uri = "https://xyzabc.com//Mats//";
FtpWebRequest reqFTP;

// Create FtpWebRequest object from the Uri provided
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(uri));
2

There are 2 answers

0
Claudio P On

This is not possible, because FtpWebRequest doesn't have a method called Create

(FtpWebRequest)FtpWebRequest.Create(new Uri(uri));

Try it with WebRequest:

(FtpWebRequest)WebRequest.Create(new Uri(uri));
0
Collin On

Took it from the Msdn FtpWebRequestClass information: https://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest(v=vs.110).aspx

This is their solution

FtpWebRequest request = (FtpWebRequest)WebRequest.Create(serverUri);

Their is also more information on the site about the properties and method of the FtpWebRequest class, also there are some examples of how it works.

Like rexcfnghk import isnt c# syntax, it should be using