Esempio n. 1
0
        public FtpResponse AssureConnected( )
        {
            FtpResponse resp = null;

            if (IsConnected == false)
            {
                resp = Connect();
            }
            return(resp);
        }
Esempio n. 2
0
        /// <summary>
        /// Connect to the FTP server using the supplied Url, UserName and Password.
        /// Then change directory to the supplied Site and Home root paths.
        /// </summary>
        /// <returns></returns>
        public override FtpResponse Connect()
        {
            FtpResponse resp = base.Connect();

            RootPath absRoot = CompleteHomePath;

            if (absRoot != null)
            {
                ChangeDirectory(absRoot.ToString());
            }

            return(resp);
        }
Esempio n. 3
0
        public override FtpResponse ChangeDirectory(string InDirName)
        {
            FtpResponse resp = null;

            resp = base.ChangeDirectory(InDirName);

            // update the current working directory.
            if (InDirName == "..")
            {
                mCurrentPath.RemoveTail();
            }
            else
            {
                mCurrentPath.AppendTail(InDirName);
            }

            return(resp);
        }
Esempio n. 4
0
        /// <summary>
        /// make sure the current working directory is the ScopePath from
        /// the CompleteHomePath.
        /// This method assumes that the CurrentPath is accurate with respect
        /// to the working directory of the FTP client.
        /// </summary>
        /// <param name="InPath"></param>
        /// <returns></returns>
        public FtpResponse AssureCurrentDirectory(ScopePath InPath)
        {
            FtpResponse resp     = null;
            string      comPath  = null;
            int         comDepth = 0;

            // build the desired full path.
            FullPath rqsFull  = CompleteHomePath + InPath;
            int      rqsDepth = rqsFull.Depth;

            // step back the CurrentPath to a subset of requested path.
            while (true)
            {
                Pather.GetCommonPath(
                    out comPath, out comDepth,
                    rqsFull.ToString(), CurrentPath.ToString());
                if (comDepth < CurrentPath.Depth)
                {
                    resp = ChangeDirectory("..");
                }
                else
                {
                    break;
                }
            }

            string filePath = Pather.GetFilePath(rqsFull.ToString(), CurrentPath.ToString());

            if (filePath.Length > 0)
            {
                if (mCurrentPath.IsEmpty == true)
                {
                    filePath = Pather.AssureRootSlash(filePath, '\\');
                }
                ChangeDirectory(filePath);
            }

            return(resp);
        }