public FtpResponse AssureConnected( ) { FtpResponse resp = null; if (IsConnected == false) { resp = Connect(); } return(resp); }
/// <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); }
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); }
/// <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); }