/// <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); }