Пример #1
0
        /// <summary>
        /// change the working directory to a ScopePath off of the site
        /// RootPath.
        /// </summary>
        /// <param name="InPath"></param>
        public void ChangeDirectoryToScopePath(ScopePath InPath)
        {
            RootPath absHomePath = CompleteHomePath;

            // if this FtpClient object contains a SitePath and/or HomePath, then
            // can only change the absolute dir path to a ScopePath.
            if (absHomePath == null)
            {
                throw new FtpException(
                          "Cannot change dir to absolute scope path." +
                          " FtpClient does not have a SitePath and HomeRootPath." +
                          " Use the ChangeDirectoryToFullPath method instead.");
            }

            FullPath absPath = absHomePath + InPath;

            CurrentPath.Empty();
            ChangeDirectory(absPath.ToString( ));
        }
Пример #2
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);
        }