Dev2.Data.PathOperations.Dev2FTPProvider.IsDirectoryAlreadyPresentStandardFtp C# (CSharp) Method

IsDirectoryAlreadyPresentStandardFtp() private method

private IsDirectoryAlreadyPresentStandardFtp ( IActivityIOPath path ) : bool
path IActivityIOPath
return bool
        bool IsDirectoryAlreadyPresentStandardFtp(IActivityIOPath path)
        {
            FtpWebResponse response = null;

            bool isAlive;

            try
            {
                FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ConvertSslToPlain(path.Path));
                request.Method = WebRequestMethods.Ftp.ListDirectory;
                request.UseBinary = true;
                request.KeepAlive = false;
                request.EnableSsl = EnableSsl(path);

                if(path.Username != string.Empty)
                {
                    request.Credentials = new NetworkCredential(path.Username, path.Password);
                }

                if(path.IsNotCertVerifiable)
                {
                    ServicePointManager.ServerCertificateValidationCallback = AcceptAllCertifications;
                }

                using(response = (FtpWebResponse)request.GetResponse())
                {

                    using(Stream responseStream = response.GetResponseStream())
                    {
                        if(responseStream != null)
                        {
                            using(StreamReader reader = new StreamReader(responseStream))
                            {

                                if(reader.EndOfStream)
                                {
                                    // just check for exception, slow I know, but not sure how else to tackle this                  
                                }
                            }
                        }
                    }
                }

                // exception will be thrown if not present
                isAlive = true;
            }
            catch(WebException wex)
            {
                Dev2Logger.Log.Error(this, wex);
                isAlive = false;
            }
            catch(Exception ex)
            {
                Dev2Logger.Log.Error(this, ex);
                throw;
            }
            finally
            {
                if(response != null)
                {
                    response.Close();
                }
            }
            return isAlive;
        }