GSF.Net.Ftp.FtpClient.SetCurrentDirectory C# (CSharp) Method

SetCurrentDirectory() public method

Changes the current FTP session directory to the specified path.
public SetCurrentDirectory ( string directoryPath ) : void
directoryPath string New directory.
return void
        public void SetCurrentDirectory(string directoryPath)
        {
            if (!IsConnected)
                throw new InvalidOperationException("You must be connected to the FTP server before you can set the current directory.");

            if (directoryPath.Length > 0)
            {
                m_currentState.CurrentDirectory = new FtpDirectory((FtpSessionConnected)m_currentState, CaseInsensitive, directoryPath);
                m_currentState.CurrentDirectory.Refresh();
            }
        }

Usage Example

示例#1
0
        /// <summary>
        /// Clones FTP session used by file watcher so it can be used for other purposes.
        /// </summary>
        /// <returns>New connected FTP session matching settings defined for FTP file watcher.</returns>
        public virtual FtpClient CloneFtpSession()
        {
            // This method is just for convenience.  We can't allow the end user to use the
            // actual internal directory for sending files or other work because it is
            // constantly being refreshed/used etc., so we instead create a new FTP Session
            // based on the current internal session and watch directory information
            FtpClient newSession = new FtpClient(m_session.CaseInsensitive);

            newSession.Server = m_session.Server;
            newSession.Connect(m_username, m_password);
            newSession.SetCurrentDirectory(m_watchDirectory);

            return(newSession);
        }
All Usage Examples Of GSF.Net.Ftp.FtpClient::SetCurrentDirectory