public:
static bool ListFilesOnServerSsl(Uri* serverUri)
{
// The serverUri should start with the ftp:// scheme.
if (serverUri->Scheme != Uri::UriSchemeFtp)
{
return false;
}
// Get the object used to communicate with the server.
FtpWebRequest* request = dynamic_cast<FtpWebRequest*>(WebRequest::Create(serverUri));
request->Method = FtpMethods::ListDirectory;
request->EnableSsl = true;
// Get the ServicePoint object used for this request, and limit it to one connection.
// In a real-world application you might use the default number of connections (2),
// or select a value that works best for your application.
ServicePoint* sp = request->ServicePoint;
Console::WriteLine(S"ServicePoint connections = {0}.", __box(sp->ConnectionLimit));
sp->ConnectionLimit = 1;
FtpWebResponse* response = dynamic_cast<FtpWebResponse*> (request->GetResponse());
Console::WriteLine(S"The content length is {0}", __box(response->ContentLength));
// The following streams are used to read the data returned from the server.
Stream* responseStream = 0;
StreamReader* readStream = 0;
responseStream = response->GetResponseStream();
readStream = new StreamReader(responseStream, System::Text::Encoding::UTF8);
// Display the data received from the server.
Console::WriteLine(readStream->ReadToEnd());
Console::WriteLine(S"List status: {0}",response->StatusDescription);
readStream->Close();
response->Close();
Console::WriteLine(S"Banner message: {0}",
response->BannerMessage);
Console::WriteLine(S"Welcome message: {0}",
response->WelcomeMessage);
Console::WriteLine(S"Exit message: {0}",
response->ExitMessage);
return true;
}