Пример #1
0
        private bool LoadDirectory(string path)
        {
            Logger.Log("Request directory listing for '{0}/{1}'", m_Session.SessionName, path);
            DirListingCallback dirCallback = delegate(RequestResult result, List <FileEntry> files)
            {
                switch (result)
                {
                case RequestResult.RetryAuthentication:
                    dlgLogin m_Login = new dlgLogin(m_Session);
                    if (m_Login.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        m_Session.Username = m_Login.Username;
                        m_Session.Password = m_Login.Password;
                        LoadDirectory(path);
                    }
                    break;

                case RequestResult.ListingFollows:
                    Console.WriteLine("Remote host returned {0} File entries", files.Count);
                    RefreshListView(files);
                    break;

                case RequestResult.UnknownError:
                    Logger.Log("Unknown Error trying to get file listing");
                    break;

                case RequestResult.InvalidArguments:
                    Logger.Log("Invalid Arguments Passed to scp");
                    break;

                case RequestResult.SessionInvalid:
                    Logger.Log("Session is invalid");
                    break;

                default:
                    Logger.Log("Unknown result '{0}'", result);
                    break;
                }
            };

            m_Transfer.BeginGetDirectoryListing(path, dirCallback);
            return(true);
        }